/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 544.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 3ms 540.0 KiB
#6 Accepted 1ms 452.0 KiB
#7 Accepted 1ms 552.0 KiB
#8 Accepted 35ms 576.0 KiB

Code

#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int t; cin >> t;
  while (t--) {
    int n, ans (0); string s;
    cin >> n >> s;
    map<char,int> L, R;
    for (auto& x:s) R[x]++;
    for (auto& x:s) {
      L[x]++; R[x]--;
      for (char c('a'); c <= 'z'; c++) {
        if ((L[c] == R[c]) && (c != x) && L[c] != 0) {
          ans++; break;
        }
      }
    }
    cout << ans << '\n';
  }
}

Information

Submit By
Type
Submission
Problem
P1021 Pivot points
Language
C++17 (G++ 13.2.0)
Submit At
2024-03-26 15:57:27
Judged At
2024-03-26 15:57:27
Judged By
Score
100
Total Time
35ms
Peak Memory
576.0 KiB