/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 2ms 324.0 KiB
#3 Accepted 2ms 320.0 KiB
#4 Accepted 2ms 316.0 KiB
#5 Accepted 3ms 324.0 KiB
#6 Accepted 2ms 548.0 KiB
#7 Accepted 2ms 320.0 KiB
#8 Accepted 39ms 568.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-11-11 03:40:12
Judged By
Score
100
Total Time
39ms
Peak Memory
568.0 KiB