# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163969 | 2019-11-16T12:45:00 Z | Leonardo_Paes | Street Lamps (APIO19_street_lamps) | C++17 | 1031 ms | 19188 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5+10; int n, q; string initial; vector<int> toggles; vector<int> events[maxn]; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin >> n >> q; initial.resize(n+2); for(int i=1; i<=n; i++){ cin >> initial[i]; if(initial[i]=='1') events[i].push_back(0); } if(n<=100 and q<=100){ toggles.push_back(0); for(int t=1; t<=q; t++){ string op; cin >> op; if(op[0] == 'q'){ int a, b; cin >> a >> b; string now = initial; int ans = 0; for(int i=0; i<toggles.size(); i++){ if(now[toggles[i]]=='0') now[toggles[i]] = '1'; else now[toggles[i]] = '0'; bool ok = true; for(int j=a; j<b; j++) if(now[j] == '0') ok = false; if(ok) ans++; } cout << ans << endl; toggles.push_back(0); } else{ int i; cin >> i; toggles.push_back(i); } } } else{ for(int t=1; t<=q; t++){ string op; cin >> op; if(op[0] == 'q'){ int a, b; cin >> a >> b; int ans = 0; for(int i=0; i<events[a].size(); i++){ if(i%2){ ans += events[a][i] - events[a][i-1]; } } if(events[a].size()%2) ans += t - events[a].back(); cout << ans << endl; } else{ int i; cin >> i; events[i].push_back(t); } } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 7416 KB | Output is correct |
2 | Correct | 8 ms | 7416 KB | Output is correct |
3 | Correct | 8 ms | 7416 KB | Output is correct |
4 | Correct | 9 ms | 7416 KB | Output is correct |
5 | Correct | 9 ms | 7416 KB | Output is correct |
6 | Correct | 9 ms | 7416 KB | Output is correct |
7 | Correct | 9 ms | 7416 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 598 ms | 9448 KB | Output is correct |
2 | Correct | 524 ms | 9252 KB | Output is correct |
3 | Correct | 507 ms | 9524 KB | Output is correct |
4 | Correct | 653 ms | 15096 KB | Output is correct |
5 | Correct | 677 ms | 18264 KB | Output is correct |
6 | Correct | 517 ms | 15224 KB | Output is correct |
7 | Correct | 942 ms | 8448 KB | Output is correct |
8 | Correct | 1031 ms | 19188 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 7416 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 7416 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 7416 KB | Output is correct |
2 | Correct | 8 ms | 7416 KB | Output is correct |
3 | Correct | 8 ms | 7416 KB | Output is correct |
4 | Correct | 9 ms | 7416 KB | Output is correct |
5 | Correct | 9 ms | 7416 KB | Output is correct |
6 | Correct | 9 ms | 7416 KB | Output is correct |
7 | Correct | 9 ms | 7416 KB | Output is correct |
8 | Correct | 598 ms | 9448 KB | Output is correct |
9 | Correct | 524 ms | 9252 KB | Output is correct |
10 | Correct | 507 ms | 9524 KB | Output is correct |
11 | Correct | 653 ms | 15096 KB | Output is correct |
12 | Correct | 677 ms | 18264 KB | Output is correct |
13 | Correct | 517 ms | 15224 KB | Output is correct |
14 | Correct | 942 ms | 8448 KB | Output is correct |
15 | Correct | 1031 ms | 19188 KB | Output is correct |
16 | Incorrect | 8 ms | 7416 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |