Submission #1005010

#TimeUsernameProblemLanguageResultExecution timeMemory
1005010vjudge1Street Lamps (APIO19_street_lamps)C++17
20 / 100
257 ms1288 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, q, store[N]; string s; pair<int, int> last[N]; int main(){ cin >> n >> q >> s; if (n <= 100 and q <= 100){ vector<string> vec; vec.push_back(s); for (int i = 0; i < q; i ++){ string qx; cin >> qx; if (qx[0] == 't'){ int x; cin >> x; x--; s[x] = '1' - s[x] + '0'; } else{ int a, b; cin >> a >> b; a--, b--; int ans = 0; for (string x : vec){ bool good = 1; for (int i = a; i < b; i ++) if (x[i] == '0') good = 0; ans += good; } cout << ans << endl; } vec.push_back(s); } return 0; } for (int i = 0; i < n; i ++) if (s[i] == '1') last[i] = {0, -1}; int tme = 1; for (int i = 0; i < q; i ++){ string qx; cin >> qx; if (qx[0] == 't'){ int x; cin >> x; x--; if (s[x] == '1'){ last[x].second = tme; s[x] = '0'; store[x] += last[x].second - last[x].first + 1; } else{ last[x] = {tme, -1}; s[x] = '1'; } } else{ int a, b; cin >> a >> b; a--, b--; int val = 0; if (last[a].second == -1 and last[a].first != -1) val = tme - last[a].first; // cout << a << " : " << last[a].first << " " << last[a].second << ", cur time = " << tme << endl; cout << store[a] + val << endl; } tme++; } }
#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...