/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 556.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 1ms 516.0 KiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 540.0 KiB
#8 Accepted 10ms 1.328 MiB

Code

#include<bits/stdc++.h>
using namespace std;
//ofstream file("output0.txt");

void solve()
{
    int n; cin>>n;
    string s; cin>>s;
    int a[n][26]={0};
    int b[26]={0};

    for(int i=0;i<n;i++)
    {
        b[s[i]-'a']++;
        for(int j=0;j<26;j++)
        {
            a[i][j]=b[j];
        }
    }

    int ans=0;

    for(int i=0;i<n;i++)
    {
        int point = s[i]-'a';
        for(int j=0;j<26;j++)
        {
            if(j==point) continue;
            if(a[i][j]!=0 && a[i][j]*2==b[j])
            {
                ans++;
                break;
            }
        }
    }

    //file<<ans<<endl;
    cout<<ans<<endl;
}
int main(){
    
    int t; cin>>t; while(t--) solve();
    //file.close();

    }

Information

Submit By
Type
Submission
Problem
P1021 Pivot points
Language
C++20 (G++ 13.2.0)
Submit At
2024-01-03 18:48:56
Judged At
2024-11-11 03:44:30
Judged By
Score
100
Total Time
10ms
Peak Memory
1.328 MiB