답안 #471446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -