# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
359033 | 2021-01-26T09:26:20 Z | valerikk | 가로등 (APIO19_street_lamps) | C++17 | 5000 ms | 48384 KB |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; int n, q; string tp[N], s; vector<int> ch[N]; int a[N], b[N]; int lst[N]; vector<int> qr[N]; int ans[N]; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q >> s; for (int i = 0; i < n; ++i) ch[i].push_back(0); for (int i = 0; i < q; ++i) { cin >> tp[i]; if (tp[i] == "toggle") { int pos; cin >> pos; --pos; ch[pos].push_back(i + 1); } else { cin >> a[i] >> b[i]; --a[i]; --b[i]; qr[a[i]].push_back(i); } } for (int i = 0; i <= q; ++i) lst[i] = n; for (int i = n - 1; i >= 0; --i) { int cur = s[i] - '0'; for (int j = 0; j < ch[i].size(); ++j) { if (cur == 0) { int nxt = j == (int)ch[i].size() - 1 ? q + 1 : ch[i][j + 1]; for (int k = ch[i][j]; k < nxt; ++k) lst[k] = i; } cur ^= 1; } for (int x : qr[i]) { for (int j = 0; j <= x; ++j) { if (lst[j] >= b[x]) ans[x] += 1; } } } for (int i = 0; i < q; ++i) { if (tp[i] == "query") cout << ans[i] << "\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23788 KB | Output is correct |
2 | Correct | 16 ms | 23916 KB | Output is correct |
3 | Correct | 15 ms | 23788 KB | Output is correct |
4 | Correct | 15 ms | 23788 KB | Output is correct |
5 | Correct | 16 ms | 23788 KB | Output is correct |
6 | Correct | 15 ms | 23916 KB | Output is correct |
7 | Correct | 15 ms | 23788 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5046 ms | 33752 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23916 KB | Output is correct |
2 | Correct | 19 ms | 23916 KB | Output is correct |
3 | Correct | 16 ms | 23916 KB | Output is correct |
4 | Correct | 18 ms | 23916 KB | Output is correct |
5 | Execution timed out | 5054 ms | 41444 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23916 KB | Output is correct |
2 | Correct | 17 ms | 23916 KB | Output is correct |
3 | Correct | 17 ms | 23916 KB | Output is correct |
4 | Correct | 19 ms | 23916 KB | Output is correct |
5 | Execution timed out | 5062 ms | 48384 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23788 KB | Output is correct |
2 | Correct | 16 ms | 23916 KB | Output is correct |
3 | Correct | 15 ms | 23788 KB | Output is correct |
4 | Correct | 15 ms | 23788 KB | Output is correct |
5 | Correct | 16 ms | 23788 KB | Output is correct |
6 | Correct | 15 ms | 23916 KB | Output is correct |
7 | Correct | 15 ms | 23788 KB | Output is correct |
8 | Execution timed out | 5046 ms | 33752 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |