#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
const int MAXN = 500100;
int n, q;
bool lamp[MAXN];
bool intervals[110][110];
void saveIntervals (int time) {
FOR(i, 1, n) intervals[time][i] = lamp[i];
}
int query (int a, int b, int time) {
int ret = 0;
FOR(t, 0, time-1) {
bool ok = true;
FOR(i, a, b-1) {
if (!intervals[t][i])
ok = false;
}
if (ok) ret++;
}
return ret;
}
int main()
{
FAST_IO;
cin >> n >> q;
string s;
cin >> s;
FOR(i, 0, n-1) {
lamp[i+1] = (s[i] == '1');
}
saveIntervals (0);
FOR(i, 1, q) {
string t;
cin >> t;
if (t[0] == 'q') {
int a, b;
cin >> a >> b;
cout << query(a,b, i) << "\n";
} else {
int id; cin >> id;
lamp[id] = !lamp[id];
}
saveIntervals (i);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
424 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
10 ms |
1668 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
25 ms |
420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
81 ms |
392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
424 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Runtime error |
10 ms |
1668 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |