| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 594930 | penguinhacker | 가로등 (APIO19_street_lamps) | C++17 | 5034 ms | 33508 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
const int mxN=3e5;
int n, q, ans[mxN], st[mxN];
string s;
vector<int> changes[mxN];
vector<ar<int, 2>> qry[mxN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q >> s;
for (int i=0; i<n; ++i)
if (s[i]=='0')
changes[i].push_back(-1);
for (int i=0; i<q; ++i) {
string type;
cin >> type;
if (type=="toggle") {
int x;
cin >> x, --x;
changes[x].push_back(i);
} else {
int l, r;
cin >> l >> r, --l, r-=2;
qry[r].push_back({l, i});
}
ans[i]=-1;
}
for (int i=0; i<n; ++i) {
for (int j=0; j<changes[i].size(); j+=2) {
int b=j+1<changes[i].size()?changes[i][j+1]:q-1;
for (int k=changes[i][j]+1; k<=b; ++k)
st[k]=i+1;
}
for (auto [l, t] : qry[i]) {
ans[t]=0;
for (int j=0; j<=t; ++j)
ans[t]+=st[j]<=l;
}
}
for (int i=0; i<q; ++i)
if (~ans[i])
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... | ||||
