# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916863 | 2024-01-26T15:59:42 Z | duckindog | Street Lamps (APIO19_street_lamps) | C++14 | 92 ms | 24752 KB |
//from duckindog wth depression #include<bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, q; int a[N]; struct Query { int ty, x, y; Query() : ty(0), x(0), y(0) {} Query(int ty, int x, int y) : ty(ty), x(x), y(y) {} } Q[N]; string s[N]; void sub1() { cin >> s[1]; for (int i = 1; i <= q; ++i) { s[i + 1] = s[i]; string ty; cin >> ty; if (ty == "toggle") { int p; cin >> p; s[i + 1][p - 1] = (s[i + 1][p - 1] == '0' ? '1' : '0'); } else { int a, b; cin >> a >> b; int answer = 0; for (int j = 1; j <= i; ++j) { bool pass = 1; for (int t = a - 1; t < b - 1; ++t) if (s[j][t] == '0') pass = 0; answer += pass; } cout << answer << '\n'; } } } int cnt[N], t[N]; int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("duck.inp", "r")) { freopen("duck.inp", "r", stdin); freopen("duck.out", "w", stdout); } cin >> n >> q; if (n <= 100 && q <= 100) { sub1(); return 0; } for (int i = 1; i <= n; ++i) { char x; cin >> x; a[i] = (x == '1'); } bool s2 = 1; for (int i = 1; i <= q; ++i) { string ty; cin >> ty; if (ty == "toggle") { int x; cin >> x; Q[i] = {0, x, 0}; } else { int x, y; cin >> x >> y; Q[i] = {1, x, y}; s2 &= (y - x == 1); } } if (s2) { for (int i = 1; i <= n; ++i) { t[i] = (a[i] == 1); } for (int i = 1; i <= q; ++i) { int ty = Q[i].ty, x = Q[i].x, y = Q[i].y; if (!ty) { if (a[x] == 1) { cnt[x] += i - t[x] + 1; t[x] = i + 1; } else { t[x] = i + 1; } a[x] = 1 - a[x]; } else { int answer = 0; if (a[x]) { answer = cnt[x] + i - t[x] + 1; } else { answer = cnt[x]; } cout << answer << '\n'; } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 13404 KB | Output is correct |
2 | Correct | 4 ms | 13404 KB | Output is correct |
3 | Correct | 4 ms | 13432 KB | Output is correct |
4 | Correct | 4 ms | 13404 KB | Output is correct |
5 | Correct | 4 ms | 13404 KB | Output is correct |
6 | Correct | 4 ms | 13404 KB | Output is correct |
7 | Correct | 4 ms | 13404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 17580 KB | Output is correct |
2 | Correct | 56 ms | 17892 KB | Output is correct |
3 | Correct | 60 ms | 18496 KB | Output is correct |
4 | Correct | 71 ms | 22612 KB | Output is correct |
5 | Correct | 70 ms | 23124 KB | Output is correct |
6 | Correct | 68 ms | 22320 KB | Output is correct |
7 | Correct | 78 ms | 23356 KB | Output is correct |
8 | Correct | 92 ms | 24752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 13404 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 13404 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 13404 KB | Output is correct |
2 | Correct | 4 ms | 13404 KB | Output is correct |
3 | Correct | 4 ms | 13432 KB | Output is correct |
4 | Correct | 4 ms | 13404 KB | Output is correct |
5 | Correct | 4 ms | 13404 KB | Output is correct |
6 | Correct | 4 ms | 13404 KB | Output is correct |
7 | Correct | 4 ms | 13404 KB | Output is correct |
8 | Correct | 55 ms | 17580 KB | Output is correct |
9 | Correct | 56 ms | 17892 KB | Output is correct |
10 | Correct | 60 ms | 18496 KB | Output is correct |
11 | Correct | 71 ms | 22612 KB | Output is correct |
12 | Correct | 70 ms | 23124 KB | Output is correct |
13 | Correct | 68 ms | 22320 KB | Output is correct |
14 | Correct | 78 ms | 23356 KB | Output is correct |
15 | Correct | 92 ms | 24752 KB | Output is correct |
16 | Incorrect | 4 ms | 13404 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |