제출 #359033

#제출 시각아이디문제언어결과실행 시간메모리
359033valerikk가로등 (APIO19_street_lamps)C++17
20 / 100
5062 ms48384 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; int n, q; string tp[N], s; vector<int> ch[N]; int a[N], b[N]; int lst[N]; vector<int> qr[N]; int ans[N]; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q >> s; for (int i = 0; i < n; ++i) ch[i].push_back(0); for (int i = 0; i < q; ++i) { cin >> tp[i]; if (tp[i] == "toggle") { int pos; cin >> pos; --pos; ch[pos].push_back(i + 1); } else { cin >> a[i] >> b[i]; --a[i]; --b[i]; qr[a[i]].push_back(i); } } for (int i = 0; i <= q; ++i) lst[i] = n; for (int i = n - 1; i >= 0; --i) { int cur = s[i] - '0'; for (int j = 0; j < ch[i].size(); ++j) { if (cur == 0) { int nxt = j == (int)ch[i].size() - 1 ? q + 1 : ch[i][j + 1]; for (int k = ch[i][j]; k < nxt; ++k) lst[k] = i; } cur ^= 1; } for (int x : qr[i]) { for (int j = 0; j <= x; ++j) { if (lst[j] >= b[x]) ans[x] += 1; } } } for (int i = 0; i < q; ++i) { if (tp[i] == "query") cout << ans[i] << "\n"; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int j = 0; j < ch[i].size(); ++j) {
      |                         ~~^~~~~~~~~~~~~~
#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...