# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
267101 | kimbj0709 | Street Lamps (APIO19_street_lamps) | C++14 | 147 ms | 15756 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 300050
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,q;
cin >> n >> q;
string input;
cin >> input;
vector<int> currpos(maxn,0);
vector<int> sum(maxn,0);
vector<int> last(maxn,-1);
for(int i=0;i<input.length();i++){
if(input.at(i)=='1'){
currpos[i+1] = 1;
last[i+1] = 0;
}
}
string input1;
int input2,input3;
for(int i=1;i<=q;i++){
cin >> input1;
if(input1=="toggle"){
cin >> input2;
if(currpos[input2]==1){
currpos[input2] = 0;
//last[input2] = i;
sum[input2] += i-last[input2];
}
else{
currpos[input2] = 1;
last[input2] = i;
}
}
else{
cin >> input2 >> input3;
input3--;
int ans = sum[input2];
if(currpos[input2]==1){
ans += i-last[input2];
}
cout << ans << "\n";
}
}
}
Compilation message (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... |