Submission #598136

#TimeUsernameProblemLanguageResultExecution timeMemory
598136OzyStreet Lamps (APIO19_street_lamps)C++17
20 / 100
518 ms15624 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define MAX 300000 struct x{ lli estado; lli val; lli ultmod; }; string st; lli q,n,a,b,res,dif; x arr[MAX+2]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q; cin >> st; rep(i,0,n-1) { if (st[i] == '0') arr[i+1] = {0,0,0}; else arr[i+1] = {1,0,0}; } rep(i,1,q) { cin >> st >> a; if (st[0] == 't') { dif = i - arr[a].ultmod; arr[a].val += dif*arr[a].estado; arr[a].estado ^= 1; arr[a].ultmod = i; } else { cin >> b; dif = i - arr[a].ultmod; arr[a].val += dif*arr[a].estado; arr[a].ultmod = i; cout << arr[a].val << endl; } } }
#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...