# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
510747 | amukkalir | Street Lamps (APIO19_street_lamps) | C++17 | 654 ms | 9972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const int nax = 3e5;
int n, q;
int bit[nax+5];
int s[nax+5];
int mn[nax+5], st[nax+5];
void upd(int idx, int val) {
for (int i = idx; i<=n; i += i & (-i)) {
bit[i] += val;
}
}
int sum(int idx) {
int ret = 0;
for(int i = idx; i>0; i -= (i & (-i))) {
ret += bit[i];
}
return ret;
}
int get(int l, int r) {
return sum(r) - sum(l-1);
}
signed main () {
scanf("%d %d", &n,&q);
for(int i=1; i<=n; i++) {
int x;
scanf("%1d", &x);
s[i] = x;
}
for(int t=1; t<=q; t++) {
string ts; cin >> ts;
if(ts == "query") {
int a, b; scanf("%d %d", &a, &b);
int ans = 0;
if(s[a]) {
ans = t - mn[a];
} else {
ans = t - mn[a] - (t-st[a]);
}
printf("%d\n", ans);
} else {
int x; scanf("%d", &x);
if(s[x]) st[x] = t;
else {
mn[x] += t - st[x];
st[x] = 0;
}
s[x] ^= 1;
}
}
}
컴파일 시 표준 에러 (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... |