# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154729 | Pro_ktmr | 가로등 (APIO19_street_lamps) | C++14 | 1434 ms | 28468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
int N,Q;
string def;
int t[300000],a[300000],b[300000];
vector<int> toggle[300000];
int ans[300000] = {};
int idx[300000] = {};
int main(){
cin >> N >> Q;
cin >> def;
for(int i=0; i<N; i++){
if(def[i] == '1') toggle[i].push_back(0);
}
for(int i=0; i<Q; i++){
string type;
cin >> type;
if(type == "toggle"){
t[i] = 0;
cin >> a[i];
a[i]--;
toggle[a[i]].push_back(i+1);
}
else{
t[i] = 1;
cin >> a[i] >> b[i];
a[i]--; b[i]--;
while(toggle[a[i]].size() > idx[a[i]] + 1){
ans[a[i]] += toggle[a[i]][idx[a[i]]+1] - toggle[a[i]][idx[a[i]]];
idx[a[i]] += 2;
}
int tmp = ans[a[i]];
if(toggle[a[i]].size()%2 == 1){
tmp += i+1 - toggle[a[i]].back();
}
cout << tmp << endl;
}
}
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... |