제출 #1119292

#제출 시각아이디문제언어결과실행 시간메모리
1119292Dan4LifeFountain (eJOI20_fountain)C++17
100 / 100
768 ms40268 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long #define sz(a) (int)a.size() using ar2 = array<int,2>; const int N = (int)1e6+10; const int LG = 20; int n, q, nxt; int d[N], c[N], nx[N]; ar2 jmp[LG][N]; stack<int> S; int32_t main(){ cin >> n >> q; for(int i = 1; i <= n; i++) cin >> d[i] >> c[i]; fill(nx,nx+n+1,n+1); for(int i = n; i >= 1; i--){ while(sz(S) and d[i] >= d[S.top()]) S.pop(); if(sz(S)) nx[i] = S.top(); S.push(i); } for(int i = 1; i <= n; i++) jmp[0][i] = {nx[i], c[i]}; for(int j = 1; j < LG; j++) for(int i = 1; i <= n; i++) nxt = jmp[j-1][i][0], jmp[j][i] = {jmp[j-1][nxt][0], jmp[j-1][i][1]+jmp[j-1][nxt][1]}; for(int i = 1; i <= q; i++){ int x, v; cin >> x >> v; for(int k = LG-1; k>=0; k--) if(jmp[k][x][0] and v>jmp[k][x][1]) v-=jmp[k][x][1],x=jmp[k][x][0]; if(x==n+1) x=0; cout << x << "\n"; } }

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

fountain.cpp: In function 'int32_t main()':
fountain.cpp:33:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   33 |   if(x==n+1) x=0; cout << x << "\n";
      |   ^~
fountain.cpp:33:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |   if(x==n+1) x=0; cout << x << "\n";
      |                   ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...