Submission #251381

#TimeUsernameProblemLanguageResultExecution timeMemory
251381jeqchoStreet Lamps (APIO19_street_lamps)C++17
0 / 100
5096 ms2688 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define f first #define s second int const N=3e5; int base[N]; int tbase[N]; bitset<N> state; int n,q; string S; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>q; F0R(i,n) { fill(base,base+n,0); fill(tbase,tbase+n,0); } cin>>S; F0R(i,n) { if(S[i]=='1')state[i]=1; else state[i]=0; } string typ; int i,a,b; int t=1; while(q--) { cin>>typ; if(typ[0]=='t') { cin>>i; --i; base[i] += (state[i]) * (t - tbase[i]); state[i] = !state[i]; tbase[i] = t; } else { cin>>a>>b; --a; --b; cout<<base[a] + state[a] * (t - tbase[a])<<'\n'; } ++t; } 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...