Submission #1005020

#TimeUsernameProblemLanguageResultExecution timeMemory
1005020vjudge1Street Lamps (APIO19_street_lamps)C++17
20 / 100
6 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=105; int const mod=1e9+7; int n,q; string s; int ans[N][N]; set<int> blocked; int check(int a,int b){ if( (blocked.lower_bound(a))==blocked.end() || (*(blocked.lower_bound(a)))>=b) return 1; return 0; } void solve1(){ cin>>s; for(int i=0;i<n;i++) if(s[i]=='0') blocked.insert(i); while(q--){ for(int i=0;i<=n;i++) for(int j=i;j<=n;j++) ans[i][j]+=check(i,j); string o; cin>>o; if(o=="toggle"){ int t; cin>>t; t--; if(s[t]=='1'){ blocked.insert(t); s[t]='0'; } else{ blocked.erase(t); s[t]='1'; } } else{ int a,b; cin>>a>>b; a--;b--; cout<<ans[a][b]<<endl; } } } int main(){ cin>>n>>q; if(n<=100 && q<=100) solve1(); else{ return 0; // solve2(); } 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...