# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
359033 | valerikk | 가로등 (APIO19_street_lamps) | C++17 | 5062 ms | 48384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |