Submission #985224

#TimeUsernameProblemLanguageResultExecution timeMemory
985224nninStreet Lamps (APIO19_street_lamps)C++14
20 / 100
76 ms10724 KiB
#include<bits/stdc++.h> using namespace std; int n, q, last[300005], ct[300005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>q; string s; cin>>s; for(int i=0;i<n;i++) { if(s[i]-'0'==1) last[i] = 0; else last[i] = -1; } for(int i=1;i<=q;i++) { cin>>s; if(s[0]=='q') { int a, b; cin>>a>>b; a--; b--; cout<<ct[a]+(last[a]==-1 ? 0:i-last[a])<<'\n'; } else { int a; cin>>a; a--; if(last[a]==-1) { last[a] = i; } else { ct[a] += (last[a]==-1 ? 0:i-last[a]); last[a] = -1; } } } } /* 5 7 11011 query 1 2 query 1 2 query 1 6 query 3 4 toggle 3 query 3 4 query 1 6 */
#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...