| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364315 | kawhiet | 가로등 (APIO19_street_lamps) | C++20 | 45 ms | 6284 KiB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
string s;
cin >> n >> q >> s;
vector<int> a(n);
for (int i = 0; i < n; i++) {
a[i] = s[i] - '0';
}
vector<int> last(n, -1), x(n);
for (int i = 0; i < n; i++) {
if (a[i] == 0) {
last[i] = 0;
}
}
for (int t = 1; t <= q; t++) {
string c;
cin >> c;
if (c == "toggle") {
int i;
cin >> i;
a[--i] ^= 1;
if (a[i] == 1) {
last[i] = t - 1;
} else {
x[i] += t - last[i] - 1;
}
} else {
int l, r;
cin >> l >> r;
l--; r--;
int res = x[l];
if (a[l] == 1) {
res += t - last[l] - 1;
}
cout << res << '\n';
}
}
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
