Submission #471446

# Submission time Handle Problem Language Result Execution time Memory
471446 2021-09-09T09:42:16 Z Karuk Election (BOI18_election) C++17
28 / 100
3000 ms 1104 KB
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q;
    cin>>n;
    string s;
    cin>>s;
    s="$"+s;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        int sum=0;
        int counter=0;
        for(int j=x;j<=y;j++)
        {
            if(sum==0 && s[j]=='T'){counter++;s[j]='F';}
            else if(s[j]=='T')sum--;
            else sum++;
        }
        sum=0;
        for(int j=y;j>=x;j--)
        {
            if(sum==0 && s[j]=='T'){counter++;s[j]='F';}
            else if(s[j]=='T')sum--;
            else if(s[j]=='C')sum++;
        }
        for(int j=x;j<=y;j++)
        {
            if(s[j]=='F')s[j]='T';
        }
        cout<<counter<<endl;
    }
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 324 KB Output is correct
2 Correct 12 ms 324 KB Output is correct
3 Correct 12 ms 204 KB Output is correct
4 Correct 15 ms 204 KB Output is correct
5 Correct 10 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 324 KB Output is correct
2 Correct 12 ms 324 KB Output is correct
3 Correct 12 ms 204 KB Output is correct
4 Correct 15 ms 204 KB Output is correct
5 Correct 10 ms 204 KB Output is correct
6 Execution timed out 3075 ms 1104 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 324 KB Output is correct
2 Correct 12 ms 324 KB Output is correct
3 Correct 12 ms 204 KB Output is correct
4 Correct 15 ms 204 KB Output is correct
5 Correct 10 ms 204 KB Output is correct
6 Execution timed out 3075 ms 1104 KB Time limit exceeded
7 Halted 0 ms 0 KB -