Submission #211446

#TimeUsernameProblemLanguageResultExecution timeMemory
211446VEGAnnStreet Lamps (APIO19_street_lamps)C++14
20 / 100
135 ms12364 KiB
#include <bits/stdc++.h> #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define pll pair<ll, ll> #define MP make_pair #define PB push_back #define pii pair<int, int> #define pi3 pair<pii, int> #define ft first #define sd second #define MP3(a,b,c) MP(MP(a,b),c) using namespace std; typedef long long ll; const int N = 300100; const int M = 100100; const int Q = 100100; const int CO = 200100; const int oo = 2e9; const int B = 1; const int MB = M / B + 10; string s, qr; int n, q, tp[N], lst[N], sum[N]; int main(){ #ifdef _LOCAL freopen("in.txt","r",stdin); #else ios_base::sync_with_stdio(0); cin.tie(0); #endif // _LOCAL cin >> n >> q >> s; for (int i = 0; i < n; i++){ sum[i] = 0; tp[i] = s[i] - '0'; lst[i] = 0; } for (int i = 1; i <= q; i++){ cin >> qr; if (qr[0] == 't'){ int x; cin >> x; x--; if (tp[x] == 1) sum[x] += i - lst[x]; tp[x] ^= 1; lst[x] = i; } else { int a, b; cin >> a >> b; a--; b--; int ans = sum[a]; if (tp[a] == 1) ans += i - lst[a]; cout << ans << '\n'; } } 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...