Submission #861676

# Submission time Handle Problem Language Result Execution time Memory
861676 2023-10-16T16:06:19 Z ador Election (BOI18_election) C++17
0 / 100
5 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    int N, Q;
    string V;
    vector<vector<int>> QV = {};
    cin >> N >> V >> Q;
    
    for(int i=0;i<Q;i++) {
        int L, R;
        cin >> L >> R;
        QV.push_back({L, R});
    }

    for(int i=0;i<Q;i++) {
        string votes = V.substr(QV[i][0]-1, QV[i][1]-QV[i][0]+1);
        int cv=0, tv=0, ni=0, nd=0;
        for (int j=0;j<(int)votes.size();j++) {
            if(votes[j] == 'T' && tv == cv) ni++;
            else if(votes[j] == 'T') tv++;
            else cv++;
        }
        cv = 0, tv=0;
        for (int j=0;j<(int)votes.size();j++) {
            if(votes[votes.size()-j-1] == 'T' && tv == cv) nd++;
            else if(votes[votes.size()-j-1] == 'T') tv++;
            else cv++;
        }
        cout << max(ni, nd) << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -