Submission #444236

#TimeUsernameProblemLanguageResultExecution timeMemory
444236urd05Dungeons Game (IOI21_dungeons)C++17
0 / 100
8 ms2764 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; int s[400000]; int p[400000]; int w[400000]; int l[400000]; int n; vector<long long> vec; typedef pair<long long,long long> P; P table[400001][24][6]; P nt[400001][6]; void init(int nn, vector<int> ss, vector<int> pp, vector<int> ww, vector<int> ll) { n=nn; for(int i=0;i<n;i++) { s[i]=ss[i]; p[i]=pp[i]; w[i]=ww[i]; l[i]=ll[i]; } for(int i=0;i<n;i++) { vec.push_back(s[i]); } sort(vec.begin(),vec.end()); vec.erase(unique(vec.begin(),vec.end()),vec.end()); for(int i=0;i<n;i++) { s[i]=lower_bound(vec.begin(),vec.end(),s[i])-vec.begin(); } for(int j=0;j<=vec.size();j++) { for(int i=0;i<=n;i++) { if (i==n) { nt[i][j]=P(i,0); table[i][0][j]=nt[i][j]; continue; } if (j>s[i]) { nt[i][j]=P(w[i],vec[s[i]]); } else { nt[i][j]=P(l[i],p[i]); } table[i][0][j]=nt[i][j]; } } for(int j=1;j<24;j++) { for(int k=0;k<6;k++) { for(int i=0;i<=n;i++) { table[i][j][k]=P(table[table[i][j-1][k].first][j-1][k].first,table[i][j-1][k].second+table[table[i][j-1][k].first][j-1][k].second); } } } vec.push_back(1e12); return; } int getind(int val) { return lower_bound(vec.begin(),vec.end(),val)-vec.begin(); } long long simulate(int x, int zz) { long long z=zz; while (x!=n) { int ind=getind(z); int now=x; for(int i=23;i>=0;i--) { P next=table[now][i][ind]; if (getind(z+next.second)!=ind||next.first==n) { continue; } now=next.first; z+=next.second; } z+=nt[now][ind].second; now=nt[now][ind].first; x=now; //printf("%d %d\n",x,z); } return z; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int j=0;j<=vec.size();j++) {
      |                 ~^~~~~~~~~~~~
#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...