# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161759 | Minnakhmetov | Street Lamps (APIO19_street_lamps) | C++14 | 5077 ms | 12256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |