Submission #565564

# Submission time Handle Problem Language Result Execution time Memory
565564 2022-05-21T06:26:14 Z birthdaycake Election (BOI18_election) C++17
0 / 100
5 ms 340 KB
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
 
 
 

 
int x[200001],y[200001];
signed main(){
    boost;
    
    int n; cin >> n;
    string a; cin >> a;
    int q; cin >> q;
    while(q--){
        int l,r, cur = 0, ans =0; cin >> l >> r;
        for(int i = l - 1; i < r; i++){
            y[i] = 0;
            if(a[i] == 'T') cur--;
            else cur++;
            if(cur < 0){
                y[i]++;
                cur++;
            }
            
        }
        cur = 0;
        for(int i = r - 1; i > l; i--){
            if(a[i] == 'T') cur--;
            else cur++;
            if(cur < 0){
                y[i]++;
                cur++;
            }
        }
        for(int i = l - 1; i < r; i++){
            if(y[i]) ans++;
            
        }
        cout << ans << endl;
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -