Submission #240122

#TimeUsernameProblemLanguageResultExecution timeMemory
240122wiwihoStreet Lamps (APIO19_street_lamps)C++14
20 / 100
240 ms24696 KiB
//#define NDEBUG #include <bits/stdc++.h> #include <bits/extc++.h> #define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define pf(a) push_front(a) #define pob pop_back() #define pof pop_front() #define mp(a, b) make_pair(a, b) #define F first #define S second #define mt make_tuple #define gt(t, i) get<i>(t) #define iceil(a, b) ((a + b - 1) / b) #define tomax(a, b) (a = max(a, b)) #define printv(a, b) {bool pvaspace=false; \ for(auto pva : a){ \ if(pvaspace) b << " "; pvaspace=true;\ b << pva;\ }\ b << "\n";} //#define TEST using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef long double ld; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; using tiii = tuple<int, int, int>; const ll MOD = 1000000007; const ll MAX = 2147483647; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } int main(){ StarBurstStream int n, q; cin >> n >> q; string s; cin >> s; vector<vector<pii>> e(n); for(int i = 0; i < q; i++){ string t; cin >> t; if(t == "toggle"){ int x; cin >> x; x--; e[x].eb(mp(i, 0)); } else{ int a, b; cin >> a >> b; a--; b--; e[a].eb(mp(i, 1)); } } vector<pii> ans; for(int i = 0; i < n; i++){ bool now = s[i] == '1'; int lst = -1; int t = 0; for(auto k : e[i]){ if(k.S == 0){ if(now){ t += k.F - lst; lst = -1; now = false; } else{ lst = k.F; now = true; } } else{ if(now){ t += k.F - lst; lst = k.F; } ans.eb(mp(k.F, t)); } } } lsort(ans); for(auto i : ans){ cout << i.S << "\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...