Submission #713593

#TimeUsernameProblemLanguageResultExecution timeMemory
713593bin9638Street Lamps (APIO19_street_lamps)C++17
20 / 100
3 ms720 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define N 110 #define ii pair<int,int> #define fs first #define sc second #define ld double int a[N][N],n,q; bool check(int t,int l,int r) { for(int i=l;i<=r;i++) if(a[i][t]==0) { // cout<<l<<" "<<r<<" "<<t<<endl; return 0; } return 1; } int main() { #ifdef SKY freopen("A.inp","r",stdin); freopen("A.out","w",stdout); #endif // SKY ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>q; for(int i=1;i<=n;i++) { char ch; cin>>ch; a[i][0]=ch-'0'; } for(int t=1;t<=q;t++) { for(int i=1;i<=n;i++) a[i][t]=a[i][t-1]; string type; cin>>type; if(type=="toggle") { int vt; cin>>vt; a[vt][t]^=1; }else { int l,r,res=0; cin>>l>>r; r--; for(int i=0;i<t;i++) if(check(i,l,r)) res++; cout<<res<<endl; } // for(int i=1;i<=n;i++)cout<<a[i][t]<<" ";cout<<endl; } 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...