Submission #971876

#TimeUsernameProblemLanguageResultExecution timeMemory
971876vivkostovStreet Lamps (APIO19_street_lamps)C++14
20 / 100
12 ms24668 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /*#ifdef ONLINE_JUDGE freopen("taxi.in", "r", stdin); freopen("taxi.out", "w", stdout); #endif */ } int n,q; string s[305]; string a[300005]; int l[300005],r[300005]; int answer(int l,int r,int ti) { int br=0; for(int i=0;i<ti;i++) { for(int j=l;j<r;j++) { if(s[i][j]=='0')break; if(j==r-1)br++; } } return br; } void read() { cin>>n>>q>>s[0]; for(int i=1;i<=q;i++) { cin>>a[i]>>l[i]; l[i]--; s[i]=s[i-1]; if(a[i]=="query") { cin>>r[i]; r[i]--; cout<<answer(l[i],r[i],i)<<endl; } else { s[i][l[i]]++; if(s[i][l[i]]=='2')s[i][l[i]]='0'; } } } int main() { speed(); read(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...