Submission #444260

#TimeUsernameProblemLanguageResultExecution timeMemory
444260urd05Dungeons 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<long long,long long> P; int nt[4000001][24]; P table[400001][24]; 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++) { nt[i][0]=(i==n?n:w[i]); table[i][0]=P(-s[i],s[i]); } for(int j=1;j<24;j++) { for(int i=0;i<=n;i++) { nt[i][j]=nt[nt[i][j-1]][j-1]; table[i][j]=P(min(table[i][j-1].first,table[i][j-1].second+table[nt[i][j-1]][j-1].first),table[i][j-1].second+table[nt[i][j-1]][j-1].second); } } return; } int getind(int val) { return upper_bound(vec.begin(),vec.end(),val)-vec.begin(); } long long simulate(int x, int zz) { long long z=zz; while (x!=n) { for(int i=23;i>=0;i--) { if (nt[x][i]!=n&&z>=-table[x][i].first) { z+=table[x][i].second; x=nt[x][i]; } } if (z>=s[x]) { z+=s[x]; x=w[x]; } else { z+=p[x]; x=l[x]; } } 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:26: error: 'w' was not declared in this scope
   24 |         nt[i][0]=(i==n?n:w[i]);
      |                          ^
dungeons.cpp:25:24: error: 's' was not declared in this scope
   25 |         table[i][0]=P(-s[i],s[i]);
      |                        ^
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:42:15: error: 'n' was not declared in this scope
   42 |     while (x!=n) {
      |               ^
dungeons.cpp:49:16: error: 's' was not declared in this scope
   49 |         if (z>=s[x]) {
      |                ^
dungeons.cpp:51:15: error: 'w' was not declared in this scope
   51 |             x=w[x];
      |               ^
dungeons.cpp:54:16: error: 'p' was not declared in this scope
   54 |             z+=p[x];
      |                ^
dungeons.cpp:55:15: error: 'l' was not declared in this scope
   55 |             x=l[x];
      |               ^