제출 #485836

#제출 시각아이디문제언어결과실행 시간메모리
485836rumen_m던전 (IOI21_dungeons)C++17
0 / 100
84 ms34008 KiB
#include "dungeons.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int maxn = 400005; const int logn = 35; long long nextt[maxn][logn],add[maxn][logn]; long long sums[maxn]; bool vis[maxn]; int n; vector <int> s,p,w,l; int dfs(int v) { if(v==n)return 0; if(vis[v])return sums[v]; sums[v] = s[v] + dfs(w[v]); vis[v] = 1; return sums[v]; } void init(int _n, std::vector<int> _s, std::vector<int> _p, std::vector<int> _w, std::vector<int> _l) { int i,j; n = _n; s.resize(_s.size()); for(i=0;i<_s.size();i++) s[i] = _s[i]; p.resize(_p.size()); for(i=0;i<_p.size();i++) p[i] = _p[i]; w.resize(_w.size()); for(i=0;i<_w.size();i++) w[i] = _w[i]; l.resize(_l.size()); for(i=0;i<_l.size();i++) l[i] = _l[i]; for(i=0;i<n;i++) { nextt[i][0] = l[i]; add[i][0] = p[i]; } nextt[n][0] = n; for(i=1;i<logn;i++) { for(j=0;j<=n;j++) { nextt[j][i] = nextt[nextt[j][i-1]][i-1]; add[j][i] = add[j][i-1]+add[nextt[j][i-1]][i-1]; } } for(i=0;i<=n;i++) { dfs(i); } } long long simulate(int x, int z) { if(x==n)return z; int S = s[0]; int i; for(i = logn-1;i>=0;i--) { if(z+add[x][i] < S) { z+=add[x][i]; x = nextt[x][i]; } } if(z<S){ z+=add[x][0]; x = nextt[x][0];} z+=sums[x]; return z; }

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:25:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(i=0;i<_s.size();i++)
      |          ~^~~~~~~~~~
dungeons.cpp:28:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(i=0;i<_p.size();i++)
      |          ~^~~~~~~~~~
dungeons.cpp:31:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(i=0;i<_w.size();i++)
      |          ~^~~~~~~~~~
dungeons.cpp:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(i=0;i<_l.size();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...