Submission #444232

#TimeUsernameProblemLanguageResultExecution timeMemory
444232urd05Dungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 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<int,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, long long z) { while (x!=n) { int ind=getind(z); int now=x; for(int i=23;i>=0;i--) { P nt=table[now][i][ind]; if (getind(z+nt.second)!=ind||nt.first==n) { continue; } now=nt.first; z+=nt.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++) {
      |                 ~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccZsOWUK.o: in function `main':
grader.cpp:(.text.startup+0x440): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status