# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
510692 | 2022-01-15T02:31:58 Z | amukkalir | Street Lamps (APIO19_street_lamps) | C++17 | 5000 ms | 1868 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int,int> #define fi first #define se second #define pb push_back #define mp make_pair const int nax = 100; int n, q; int ans[nax+5][nax+5]; int bit[nax+5]; int s[nax+5]; void upd(int idx, int val) { for (int i = idx; i<=n; i += i & (-i)) { bit[i] += val; } } int sum(int idx) { int ret = 0; for(int i = idx; i>0; i -= (i & (-i))) { ret += bit[i]; } return ret; } int get(int l, int r) { return sum(r) - sum(l-1); } signed main () { scanf("%d %d", &n,&q); for(int i=1; i<=n; i++) { int x; scanf("%1d", &x); if(x) upd(i,x); s[i] = x; } while(q--) { for(int i=1; i<=n+1; i++) { for(int j=i+1; j<=n+1; j++) { ans[i][j] += get(i,j-1) == (j-i); } } string ts; cin >> ts; if(ts == "query") { int a, b; scanf("%d %d", &a, &b); printf("%d\n", ans[a][b]); } else { int x; scanf("%d", &x); upd(x, s[x] == 1 ? -1 : 1); s[x] ^= 1; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 276 KB | Output is correct |
2 | Correct | 1 ms | 268 KB | Output is correct |
3 | Correct | 1 ms | 280 KB | Output is correct |
4 | Correct | 8 ms | 332 KB | Output is correct |
5 | Correct | 5 ms | 332 KB | Output is correct |
6 | Correct | 5 ms | 296 KB | Output is correct |
7 | Correct | 7 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5011 ms | 1868 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 416 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 432 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 276 KB | Output is correct |
2 | Correct | 1 ms | 268 KB | Output is correct |
3 | Correct | 1 ms | 280 KB | Output is correct |
4 | Correct | 8 ms | 332 KB | Output is correct |
5 | Correct | 5 ms | 332 KB | Output is correct |
6 | Correct | 5 ms | 296 KB | Output is correct |
7 | Correct | 7 ms | 384 KB | Output is correct |
8 | Execution timed out | 5011 ms | 1868 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |