제출 #1174686

#제출 시각아이디문제언어결과실행 시간메모리
1174686JelalTkm가로등 (APIO19_street_lamps)C++20
40 / 100
59 ms7348 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define int long long int const int N = 1000 + 10; const int md = 1e9 + 7; const int INF = 1e18; struct node { int on = -1, sm = 0; }; int32_t main(int32_t argc, char *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; // cin >> T; while (T--) { int n, q; cin >> n >> q; if (n <= 100 && q <= 100) { string s; cin >> s; s = '#' + s; vector<vector<int>> a(n + 2, vector<int> (n + 2)); while (q--) { for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) { if (s[j] == '0') break; else a[i][j + 1]++; } string c; cin >> c; if (c == "toggle") { int i; cin >> i; s[i] = (s[i] == '1' ? '0' : '1'); } else { int l, r; cin >> l >> r; cout << a[l][r] << '\n'; } } } else { string s; cin >> s; s = '#' + s; vector<node> a(n + 1); for (int i = 1; i <= n; i++) { if (s[i] == '1') { a[i].on = 0; } } int tm = 0; while (q--) { tm++; string c; cin >> c; if (c == "toggle") { int i; cin >> i; if (s[i] == '1') { a[i].sm += (tm - a[i].on); a[i].on = -1; } else { a[i].on = tm; } s[i] = (s[i] == '1' ? '0' : '1'); } else { int l, r; cin >> l >> r; cout << a[l].sm + (tm - (a[l].on == -1 ? tm : a[l].on)) << '\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...