Submission #444234

#TimeUsernameProblemLanguageResultExecution timeMemory
444234urd05Dungeons 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, int zz) { long long z=zz; 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:16:5: error: 'n' was not declared in this scope; did you mean 'nn'?
   16 |     n=nn;
      |     ^
      |     nn
dungeons.cpp:18:9: error: 's' was not declared in this scope
   18 |         s[i]=ss[i];
      |         ^
dungeons.cpp:19:9: error: 'p' was not declared in this scope
   19 |         p[i]=pp[i];
      |         ^
dungeons.cpp:20:9: error: 'w' was not declared in this scope
   20 |         w[i]=ww[i];
      |         ^
dungeons.cpp:21:9: error: 'l' was not declared in this scope
   21 |         l[i]=ll[i];
      |         ^
dungeons.cpp:24:23: error: 's' was not declared in this scope
   24 |         vec.push_back(s[i]);
      |                       ^
dungeons.cpp:29:9: error: 's' was not declared in this scope
   29 |         s[i]=lower_bound(vec.begin(),vec.end(),s[i])-vec.begin();
      |         ^
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++) {
      |                 ~^~~~~~~~~~~~
dungeons.cpp:38:19: error: 's' was not declared in this scope
   38 |             if (j>s[i]) {
      |                   ^
dungeons.cpp:39:28: error: 'w' was not declared in this scope
   39 |                 nt[i][j]=P(w[i],vec[s[i]]);
      |                            ^
dungeons.cpp:42:28: error: 'l' was not declared in this scope
   42 |                 nt[i][j]=P(l[i],p[i]);
      |                            ^
dungeons.cpp:42:33: error: 'p' was not declared in this scope
   42 |                 nt[i][j]=P(l[i],p[i]);
      |                                 ^
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:64:15: error: 'n' was not declared in this scope
   64 |     while (x!=n) {
      |               ^