Submission #167547

#TimeUsernameProblemLanguageResultExecution timeMemory
167547qkxwsmStreet Lamps (APIO19_street_lamps)C++14
20 / 100
133 ms12376 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define MAXN 300013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N, Q; int stor[MAXN]; int lst[MAXN]; pii quer[MAXN]; bitset<MAXN> state; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); cerr << fixed << setprecision(4); cin >> N >> Q; string temps; cin >> temps; FOR(i, 0, N) { state[i] = (temps[i] == '1'); lst[i] = -1; } FOR(i, 0, Q) { cin >> temps; int x, y; if (temps[0] == 't') { cin >> x; x--; quer[i] = {-1, x}; } else { cin >> x >> y; x--; y -= 2; quer[i] = {x, y}; } } FOR(i, 0, Q) { if (quer[i].fi == -1) { int idx = quer[i].se; if (state[idx]) { stor[idx] += (i - lst[idx]); } lst[idx] = i; state[idx] = state[idx] ^ 1; } else { int idx = quer[i].fi; int res = stor[idx]; if (state[idx]) res += (i - lst[idx]); cout << res << '\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...