#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
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++) {
~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5077 ms |
6624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
115 ms |
376 KB |
Output is correct |
5 |
Correct |
3633 ms |
11008 KB |
Output is correct |
6 |
Execution timed out |
5049 ms |
11388 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
5012 ms |
12256 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
296 KB |
Output is correct |
8 |
Execution timed out |
5077 ms |
6624 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |