제출 #857024

#제출 시각아이디문제언어결과실행 시간메모리
857024chanhchuong123Sum Zero (RMI20_sumzero)C++14
0 / 100
6 ms31320 KiB
#include <bits/stdc++.h> using namespace std; #define task "" const int MAX = 400040; int n, q; int c[MAX]; long long sf = 0; int jump[19][MAX]; map<long long, int> last; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n; for (int i = 1; i <= n; ++i) { cin >> c[i]; } last[0] = n + 1; for (int j = 0; j <= 18; ++j) { for (int i = 1; i <= n + 2; ++i) jump[j][i] = n + 2; } for (int i = n; i >= 1; --i) { sf += c[i]; jump[0][i] = min(jump[0][i], jump[0][i + 1]); if (last[sf] > 0) jump[0][i] = min(jump[0][i], last[sf]); last[sf] = i; } for (int j = 1; j <= 18; ++j) for (int i = 1; i <= n; ++i) jump[j][i] = jump[j - 1][jump[j - 1][i]]; cin >> q; while (q--) { int l, r, res = 0; cin >> l >> r; for (int j = 18; j >= 0; --j) { if (jump[j][l] - 1 <= r) { l = jump[j][l]; res += 1 << j; } } cout << res << '\n'; } return 0; }

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

sumzero.cpp: In function 'int main()':
sumzero.cpp:32:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |         if (last[sf] > 0) jump[0][i] = min(jump[0][i], last[sf]); last[sf] = i;
      |         ^~
sumzero.cpp:32:67: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |         if (last[sf] > 0) jump[0][i] = min(jump[0][i], last[sf]); last[sf] = i;
      |                                                                   ^~~~
sumzero.cpp:16:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sumzero.cpp:17:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...