Submission #503100

#TimeUsernameProblemLanguageResultExecution timeMemory
503100stefantagaStreet Lamps (APIO19_street_lamps)C++14
20 / 100
106 ms11660 KiB
#include <bits/stdc++.h> using namespace std; int v[300005],n,q,x,y,ult[300005],nr[300005],i,j,t; int main() { ios_base :: sync_with_stdio(false); cin.tie(0); #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n>>q; for (i=1;i<=n;i++) { char ch; cin>>ch; v[i]=ch-'0'; nr[i]=v[i]; ult[i]=1; } for (i=1;i<=q;i++) { char tip[15]; cin>>tip; if (strcmp(tip,"query")==0) { cin>>x>>y; if (v[x]==1) { cout<<nr[x]+i-ult[x]<<'\n'; } else cout<<nr[x]<<'\n'; } else { cin>>x; if (v[x]==1) { nr[x]=nr[x]+i-ult[x]; } ult[x]=i; v[x]=1-v[x]; } } 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...