Submission #255856

#TimeUsernameProblemLanguageResultExecution timeMemory
255856balbitStreet Lamps (APIO19_street_lamps)C++14
20 / 100
131 ms9720 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define f first #define s second #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #define pb push_back #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<" "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__) template<typename T> void _do(T && x ){ cerr<<x<<endl; } template<typename T, typename ...S> void _do(T && x , S&&...y){ cerr<<x<<", "; _do(y...);} #define IOS() #else #define IOS() ios::sync_with_stdio(0),cin.tie(0) #define endl '\n' #define bug(...) #endif // BALBIT const int maxn = 3e5+5; //vector<pii> g[maxn]; bool hi[maxn]; int ans[maxn], lt[maxn]; signed main(){ IOS(); int n,q; cin>>n>>q; for (int i = 0; i<n; ++i) { char c; cin>>c; hi[i] = c=='1'; if (hi[i]) { lt[i] = -1; } } for (int i = 0; i<q; ++i) { string s; cin>>s; if (s[0] == 'q') { int a, foo; cin>>a>>foo; -- a; int re = ans[a]; if (hi[a]) { re += i - lt[a]; } cout<<re<<endl; }else{ int x; cin>>x; --x; if (hi[x]) { // turning it off ans[x] += i - lt[x]; }else{ // on lt[x] = i; bug(x,lt[x]); } hi[x] ^= 1; } } }
#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...