제출 #990226

#제출 시각아이디문제언어결과실행 시간메모리
990226duzinho039Sum Zero (RMI20_sumzero)C++14
61 / 100
489 ms57680 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ii = pair<int, int>; using vii = vector<ii>; vi c; vii queries; int n, q; void read() { cin >> n; c.resize(n); for(int &x: c) cin >> x; cin >> q; queries.resize(q); for(auto &[l, r]: queries) cin >> l >> r; } void solve() { map<int, int> where; vvi anc(n, vi(15, -100)); int currsum = 0; int prev = -100; for(int i = 0; i < n; ++i) { currsum += c[i]; if(where.find(currsum) != where.end()) { prev = max(prev, where[currsum]); } if(currsum == 0) { prev = max(prev, -1); } anc[i][0] = prev; for(int b = 1; b < 15; ++b) { if(anc[i][b - 1] <= -1) { break; } anc[i][b] = anc[anc[i][b - 1]][b - 1]; } where[currsum] = i; } for(auto [l, r]: queries) { l--; r--; int ans = 0; for(int b = 14; b >= 0; --b) { if(r == -1) break; int nr = anc[r][b]; if(nr >= l - 1) { r = nr; ans |= 1 << b; } } cout << ans << '\n'; } } int main() { read(); solve(); }

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

sumzero.cpp: In function 'void read()':
sumzero.cpp:21:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   21 |  for(auto &[l, r]: queries) cin >> l >> r;
      |            ^
sumzero.cpp: In function 'void solve()':
sumzero.cpp:53:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   53 |  for(auto [l, r]: queries) {
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...