Submission #861670

#TimeUsernameProblemLanguageResultExecution timeMemory
861670adorElection (BOI18_election)C++14
0 / 100
5 ms344 KiB
#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<votes.length();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<votes.length();j++) { if(votes[votes.length()-j-1] == 'T' && tv == cv) nd++; else if(votes[votes.length()-j-1] == 'T') tv++; else cv++; } cout << max(ni, nd) << "\n"; } }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for (int j=0;j<votes.length();j++) {
      |                      ~^~~~~~~~~~~~~~~
election.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int j=0;j<votes.length();j++) {
      |                      ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...