Submission #863111

#TimeUsernameProblemLanguageResultExecution timeMemory
863111adorElection (BOI18_election)C++14
0 / 100
11 ms604 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, Q; string V; vector<vector<int>> vp; cin >> N >> V >> Q; for(int i=0;i<Q;i++) { int L, R; cin >> L >> R; vp.push_back({L, R}); } for(int i=0; i<(int)vp.size(); i++) { string subV = V.substr(vp[i][0]-1, vp[i][1]-vp[i][0]+1); int cv = 0, cvd = 0, tv = 0, tvd = 0, nulled = 0, nulledd = 0; for(int j=0;j<(int)subV.size();j++) { if(subV[j] == 'T' && cv == tv) nulled++; else if (subV[j] == 'C') cv++; else tv++; if(subV[subV.size()-j-1] == 'T' && cvd == tvd) nulledd++; else if (subV[subV.size()-j-1] == 'C') cvd++; else tvd++; } cout << max(nulled, nulledd) << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...