Submission #1196613

#TimeUsernameProblemLanguageResultExecution timeMemory
1196613Ludissey던전 (IOI21_dungeons)C++20
Compilation error
0 ms0 KiB
#include "dungeons.h"
#include <bits/stdc++.h>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using namespace std;

int N; 
vector<int> s,p,w,l;
vector<int> ss;
vector<vector<vector<int>>> nxt;
/*vector<vector<vector<int>>> nxt;
vector<vector<vector<int>>> nxp;*/
vector<long long> tw;

const int LOG=25;
const int MAXS=1e7+1;
int sn;

long long pth(int x){
	if(x==N) return 0;
	if(tw[x]>=0) return tw[x];
	tw[x]=pth(w[x])+(long long)s[x];
	return tw[x];
}

void init(signed n, std::vector<signed> S, std::vector<signed> P, std::vector<signed> W, std::vector<signed> L) {
	N=n;
	s.resize(N);
	tw.resize(N,-1);
	p.resize(N);
	w.resize(N+1);
	l.resize(N+1);
	l[N]=N;
	w[N]=N;
	for (int i = 0; i < n; i++)
	{
		s[i]=S[i];
		p[i]=P[i];
		w[i]=W[i];
		l[i]=L[i];
	}
	ss.push_back(0);
	int u=1; 
	while(u<MAXS){
		ss.push_back(u);
		u*=2;
	}
    sn=sz(ss);
	nxt.resize(N+1,vector<vector<int>>(sn*3,vector<int>(1,0)));
	for (int j = 0; j < sz(ss); j++) { nxt[n][j+sn][0]=n; nxt[n][j+2*sn][0]=1e8; }

	for (int i = 0; i < n; i++){
		for (int j = 0; j < sz(ss); j++)
		{
			if(s[i]<=ss[j]){
				nxt[i][j][0]=s[i];
				nxt[i][j+sn][0]=w[i];
				nxt[i][j+sn*2][0]=1e8;
			}else{
				nxt[i][j][0]=p[i];
				nxt[i][j+sn][0]=l[i];
				nxt[i][j+sn*2][0]=s[i];
			}
		}
		
	}
	for (int j = 1; j < LOG; j++)
	{
		for (int i = 0; i < N; i++)
		{
			for (int k = 0; k < sz(ss); k++){
				nxt[i][k+sn].push_back(nxt[nxt[i][k+sn][j-1]][k+sn][j-1]);
				nxt[i][k].push_back(nxt[i][k][j-1]+nxt[nxt[i][k+sn][j-1]][k][j-1]);
				nxt[i][k+2*sn].push_back(min(nxt[i][k+2*sn][j-1],nxt[nxt[i][k+sn][j-1]][k+2*sn][j-1]-nxt[i][k][j-1]));
			}
		}
		for (int k = 0; k < sz(ss); k++) {
			nxt[n][k].push_back(0);
			nxt[n][k+sn].push_back(0);
			nxt[n][k+2*sn].push_back(0);
		}
	}
	return;
}

long long simulate(signed x, signed z) {
	for (int i = 0; i < sz(ss); i++)
	{
		if(ss[i+1]<=cs) continue;
		for (int j = LOG-1; j >= 0; j--)
		{
			if(nxt[u][j][i+sn]==N||nxt[u][j][i+2*sn]<=cs) continue;
			cs+=nxt[u][j][i];
			u=nxt[u][j][i+sn];
		}
		if(nxt[u][0][i+sn]==N){
			if(s[u]>cs) cs+=p[u];
			else cs+=s[u];
			return cs;
		}else{
			if(s[u]>cs) {
				cs+=p[u];
				u=l[u];
			}
			else {
				cs+=s[u];
				u=w[u];
			}
		}
		if(u==N) return cs;
	}
	return (long long)cs+pth(u);
}

Compilation message (stderr)

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:91:29: error: 'cs' was not declared in this scope; did you mean 'ss'?
   91 |                 if(ss[i+1]<=cs) continue;
      |                             ^~
      |                             ss
dungeons.cpp:94:32: error: 'u' was not declared in this scope
   94 |                         if(nxt[u][j][i+sn]==N||nxt[u][j][i+2*sn]<=cs) continue;
      |                                ^
dungeons.cpp:94:67: error: 'cs' was not declared in this scope; did you mean 'ss'?
   94 |                         if(nxt[u][j][i+sn]==N||nxt[u][j][i+2*sn]<=cs) continue;
      |                                                                   ^~
      |                                                                   ss
dungeons.cpp:95:25: error: 'cs' was not declared in this scope; did you mean 'ss'?
   95 |                         cs+=nxt[u][j][i];
      |                         ^~
      |                         ss
dungeons.cpp:95:33: error: 'u' was not declared in this scope
   95 |                         cs+=nxt[u][j][i];
      |                                 ^
dungeons.cpp:98:24: error: 'u' was not declared in this scope
   98 |                 if(nxt[u][0][i+sn]==N){
      |                        ^
dungeons.cpp:99:33: error: 'cs' was not declared in this scope; did you mean 'ss'?
   99 |                         if(s[u]>cs) cs+=p[u];
      |                                 ^~
      |                                 ss
dungeons.cpp:101:32: error: 'cs' was not declared in this scope; did you mean 'ss'?
  101 |                         return cs;
      |                                ^~
      |                                ss
dungeons.cpp:103:33: error: 'cs' was not declared in this scope; did you mean 'ss'?
  103 |                         if(s[u]>cs) {
      |                                 ^~
      |                                 ss
dungeons.cpp:112:20: error: 'u' was not declared in this scope
  112 |                 if(u==N) return cs;
      |                    ^
dungeons.cpp:112:33: error: 'cs' was not declared in this scope; did you mean 'ss'?
  112 |                 if(u==N) return cs;
      |                                 ^~
      |                                 ss
dungeons.cpp:114:27: error: 'cs' was not declared in this scope; did you mean 'ss'?
  114 |         return (long long)cs+pth(u);
      |                           ^~
      |                           ss
dungeons.cpp:114:34: error: 'u' was not declared in this scope
  114 |         return (long long)cs+pth(u);
      |                                  ^