# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
267099 | kimbj0709 | Street Lamps (APIO19_street_lamps) | C++14 | 1 ms | 640 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 105
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);
for(int i=0;i<input.length();i++){
if(input.at(i)=='1'){
currpos[i+1] = 1;
}
}
int arr[maxn][maxn];
for(int i=1;i<=n;i++){
arr[0][i] = currpos[i];
arr[0][i] += arr[0][i-1];
//cout << arr[0][i] << " ";
}
//cout << endl;
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;
}
else{
currpos[input2] = 1;
}
for(int j=1;j<=n;j++){
arr[i][j] = currpos[j];
arr[i][j] += arr[i][j-1];
}
}
else{
cin >> input2 >> input3;
input3--;
int ans = 0;
for(int j=0;j<i;j++){
ans += (arr[j][input3]-arr[j][input2-1]==input3-input2+1);
}
for(int j=1;j<=n;j++){
arr[i][j] = currpos[j];
arr[i][j] += arr[i][j-1];
}
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... |