답안 #437122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
437122 2021-06-25T21:25:42 Z jeroenodb 던전 (IOI21_dungeons) C++17
37 / 100
7000 ms 114872 KB
#ifndef GRADER
#include "dungeons.h"
#endif
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 4e5+10, oo = 1e8;

int jmp[mxN][20];
bitset<mxN> mx[20];
ll sm[mxN][20];
// int jump(int a, int k) {
//     int D = max(0,d[a]-k);
//     while(d[a]>D) {
//         if(d[jmp[a]]>=D) a = jmp[a];
//         else a = par[a];
//     }
//     return a;
// }
static int N;
const int B = 7000;
vi S,P,W,L;
void init(int n, vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
	S=s,P=p,W=w,L=l;
	N=n;
	jmp[n][0]=n;
	mx[0][n]=true;
	for(int j=0;j<n;++j) {
		if(s[j]>=B) {
			jmp[j][0] = l[j], sm[j][0]=p[j];
		} else jmp[j][0] = w[j], sm[j][0] = s[j];
		mx[0][j] = s[j]>=B;
	}
	for(int i=1;i<20;++i) {
		for(int j=0;j<=n;++j) {
			jmp[j][i] = jmp[jmp[j][i-1]][i-1];
			mx[i][j] = mx[i-1][j] or mx[i-1][jmp[j][i-1]];
			sm[j][i] = sm[j][i-1]+sm[jmp[j][i-1]][i-1];
		}
	}
}
long long mysimulate(int x, ll z) {
	int n = N;
	while(z<B) {
		if(x==n) return z;
		if(z>=S[x]) {
			z+=S[x];
			x=W[x];
		} else {
			z+=P[x];
			x=L[x];
		}
	}
	// find next x: S[x]>z, can only happen log times
	// what if P[x] is very small?

	while(x!=n) {
		for(int i=19;i>=0;--i) {
			if(!mx[i][x]) {
				z+=sm[x][i];
				x=jmp[x][i];
			}
		}
		if(x==n) return z;
		if(z>=S[x]) {
			z+=S[x];
			x=W[x];
		} else {
			z+=P[x];
			x=L[x];
		}
	}
	return z;
}
long long simulate(int x, int z) {
	return mysimulate(x,z);	
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 844 KB Output is correct
4 Correct 50 ms 14532 KB Output is correct
5 Correct 2 ms 844 KB Output is correct
6 Correct 49 ms 14560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 508 ms 114748 KB Output is correct
3 Correct 480 ms 114796 KB Output is correct
4 Correct 490 ms 114808 KB Output is correct
5 Correct 505 ms 114788 KB Output is correct
6 Correct 713 ms 114780 KB Output is correct
7 Correct 855 ms 114872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 95 ms 15368 KB Output is correct
3 Execution timed out 7044 ms 15316 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 95 ms 15368 KB Output is correct
3 Execution timed out 7044 ms 15316 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 95 ms 15368 KB Output is correct
3 Execution timed out 7044 ms 15316 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 508 ms 114748 KB Output is correct
3 Correct 480 ms 114796 KB Output is correct
4 Correct 490 ms 114808 KB Output is correct
5 Correct 505 ms 114788 KB Output is correct
6 Correct 713 ms 114780 KB Output is correct
7 Correct 855 ms 114872 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
9 Correct 95 ms 15368 KB Output is correct
10 Execution timed out 7044 ms 15316 KB Time limit exceeded
11 Halted 0 ms 0 KB -