Submission #1174673

#TimeUsernameProblemLanguageResultExecution timeMemory
1174673tkm_algorithms가로등 (APIO19_street_lamps)C++20
20 / 100
68 ms16816 KiB
/** * In the name of Allah * We are nothing and you're everything * author: najmuddin **/ #include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; #define int ll const char nl = '\n'; const int N = 101; const int inf = 1e9; struct st { int dlit; int last; int ok; }; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; string s; cin >> s; s = '&'+s; vector<st> on(n+1), of(n+1); for (int i = 1; i <= n; ++i) { if (s[i] == '1') on[i].ok = 1, of[i].last = inf; else of[i].ok = 1, on[i].last = inf; } for (int _ = 1; _ <= q; ++_) { string tp; cin >> tp; if (tp == "toggle") { int pos; cin >> pos; auto& y = on[pos]; auto& x = of[pos]; if (y.ok == 1) { y.dlit += _-y.last; y.ok = 0; y.last = inf; x.ok = 1; x.last = _; } else { x.dlit += _-x.last; x.ok = 0; x.last = inf; y.ok = 1; y.last = _; } } else { int a, b; cin >> a >> b; int ans = on[a].dlit+max(0ll, _-on[a].last); cout << ans << nl; } } 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...