제출 #929722

#제출 시각아이디문제언어결과실행 시간메모리
929722abcvuitunggio던전 (IOI21_dungeons)C++17
11 / 100
7110 ms1980552 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; const int base=4,sz=13; const long long INF=1e18; int N,nxt[24][400001][sz],mn[24][400001][sz]; long long sum[24][400001][sz]; vector <int> S,P,W,L,ve={1}; void init(int n, vector <int> s, vector <int> p, vector <int> w, vector <int> l){ N=n,S=s,P=p,W=w,L=l; for (int i=1;i<sz-1;i++) ve.push_back(ve.back()*base); ve.push_back(10000001); memset(nxt,-1,sizeof(nxt)); for (int i=0;i<n;i++){ for (int j=0;j<sz;j++) if (s[i]<=ve[j]){ nxt[0][i][j]=w[i]; sum[0][i][j]=s[i]; mn[0][i][j]=INF; } else{ nxt[0][i][j]=l[i]; sum[0][i][j]=p[i]; mn[0][i][j]=s[i]; } nxt[0][i][sz]=w[i]; } for (int j=1;j<24;j++){ for (int i=0;i<n;i++) for (int k=0;k<sz;k++){ if (nxt[j-1][i][k]==-1) continue; int u=nxt[j-1][i][k]; nxt[j][i][k]=nxt[j-1][u][k]; mn[j][i][k]=min(mn[j-1][i][k],(int)max(mn[j-1][u][k]-sum[j-1][i][k],0LL)); sum[j][i][k]=sum[j-1][i][k]+sum[j-1][u][k]; } } } long long simulate(int x, int Z){ int cur=0; long long z=Z; while (x<N){ while (cur<sz&&ve[cur]<=z) cur++; if (cur==sz) break; int j=cur-1; for (int i=23;i>=0;i--) if (nxt[i][x][j]!=-1&&z<mn[i][x][j]){ z+=sum[i][x][j]; x=nxt[i][x][j]; } if (x==N) break; if (z<S[x]){ z+=P[x]; x=L[x]; } else{ z+=S[x]; x=W[x]; } } int j=cur-1; for (int i=18;i>=0;i--) if (nxt[i][x][j]!=-1){ z+=sum[i][x][j]; x=nxt[i][x][j]; } return z; }

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:20:29: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   20 |                 mn[0][i][j]=INF;
      |                             ^~~
dungeons.cpp:27:21: warning: array subscript 13 is above array bounds of 'int [13]' [-Warray-bounds]
   27 |         nxt[0][i][sz]=w[i];
      |         ~~~~~~~~~~~~^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...