# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1044631 | 2024-08-05T11:51:01 Z | Kel_Mahmut | 가로등 (APIO19_street_lamps) | C++14 | 166 ms | 18416 KB |
#include <bits/stdc++.h> #define pb push_back #define endl ("\n") #define all(aa) aa.begin(), aa.end() typedef long long ll; using namespace std; int main(){ int n, q; cin >> n >> q; vector<int> v(n); string s; cin >> s; for(int i = 0; i < n; i++) v[i] = (s[i] == '1'); vector<vector<pair<int, int>>> Q(n); for(int i = 1; i <= q; i++){ string t; cin >> t; if(t == "toggle"){ int a; cin >> a; a--; Q[a].pb({i, 0}); } else{ int l, r; cin >> l >> r; l--, r -= 2; Q[l].pb({i, 1}); } } vector<int> ans(q + 1, -1); for(int i = 0; i < n; i++){ ll one = v[i]; ll cev = 0; ll time = 0; for(auto [a, t] : Q[i]){ cev += one * (a - time); if(t == 0){ one ^=1; } else{ ans[a] = cev; } time = a; } } for(int i = 0; i <= q; i++){ if(ans[i] != -1){ cout << ans[i] << endl; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 5716 KB | Output is correct |
2 | Correct | 92 ms | 5716 KB | Output is correct |
3 | Correct | 105 ms | 6484 KB | Output is correct |
4 | Correct | 140 ms | 17136 KB | Output is correct |
5 | Correct | 143 ms | 17604 KB | Output is correct |
6 | Correct | 137 ms | 16876 KB | Output is correct |
7 | Correct | 162 ms | 16844 KB | Output is correct |
8 | Correct | 166 ms | 18416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |