# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
140532 | 2019-08-03T12:24:52 Z | luciocf | 가로등 (APIO19_street_lamps) | C++14 | 3 ms | 376 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5+10; struct Op { int type; int ind; } query[maxn]; int n, q; bool on[maxn]; bool mark[maxn]; void solve_small(void) { for (int i = 1; i <= q; i++) { string op; cin >> op; if (op == "toggle") { int ind; scanf("%d", &ind); query[i] = {0, ind}; } else { int l, r; scanf("%d %d", &l, &r); query[i] = {1, -1}; int ans = 0; for (int j = 1; j <= n; j++) mark[j] = on[j]; for (int j = 1; j <= i; j++) { if (query[j].type == 1) { bool ok = 1; for (int k = l; k < r; k++) if (!mark[k]) ok = 0; if (ok) ans++; } else { bool ok = 1; for (int k = l; k < r; k++) if (!mark[k]) ok = 0; if (ok) ans++; mark[query[j].ind] = !mark[query[j].ind]; } } printf("%d\n", ans); } } } int main(void) { scanf("%d %d", &n, &q); for (int i = 1; i <= n; i++) { char x; scanf(" %c", &x); if (x == '1') on[i] = true; } if (n <= 100 && q <= 100) { solve_small(); return 0; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 248 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 248 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |