Submission #161759

#TimeUsernameProblemLanguageResultExecution timeMemory
161759MinnakhmetovStreet Lamps (APIO19_street_lamps)C++14
20 / 100
5077 ms12256 KiB
#include <bits/stdc++.h> #define ll long long #define all(aaa) aaa.begin(), aaa.end() using namespace std; struct Q { int type, x, y; }; string s; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n, q; cin >> n >> q >> s; vector<Q> qr; for (int i = 0; i < q; i++) { string t; cin >> t; if (t[0] == 'q') { int x, y; cin >> x >> y; x--; y -= 2; qr.push_back({0, x, y}); } else { int x; cin >> x; x--; qr.push_back({1, x}); } } for (int i = 0; i < qr.size(); i++) { if (qr[i].type == 0) { string tmp = s; int ans = 0; for (int j = 0; j <= i; j++) { ans++; for (int k = qr[i].x; k <= qr[i].y; k++) { if (tmp[k] == '0') { ans--; break; } } if (qr[j].type) { tmp[qr[j].x] = '0' + (tmp[qr[j].x] == '0'); } } cout << ans << "\n"; } } return 0; }

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:43:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < qr.size(); i++) {
                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...