Submission #1082341

#TimeUsernameProblemLanguageResultExecution timeMemory
1082341HappyCapybara던전 (IOI21_dungeons)C++17
0 / 100
92 ms55984 KiB
#include "dungeons.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long

ll inf = pow(10, 8);

int n;
vector<int> s, p, w, l;
vector<vector<pair<int,ll>>> a, b;

void init(int N, vector<int> S, vector<int> P, vector<int> W, vector<int> L){
	n = N;
	s = S;
	p = P;
	w = W;
	l = L;
    s.push_back(0);
    p.push_back(0);
    w.push_back(n);
    l.push_back(n);
	a.resize(n+1, vector<pair<int,ll>>(30));
	b.resize(n+1, vector<pair<int,ll>>(30));
	for (int i=0; i<30; i++){
		for (int j=0; j<=n; j++){
			if (i == 0){
				a[j][i] = {l[j], p[j]};
				b[j][i] = {w[j], s[j]};
			}
			else {
				a[j][i].first = a[a[j][i-1].first][i-1].first;
				a[j][i].second = min(inf, a[j][i-1].second + a[a[j][i-1].first][i-1].second);
				b[j][i].first = b[b[j][i-1].first][i-1].first;
				b[j][i].second = min(inf, b[j][i-1].second + b[b[j][i-1].first][i-1].second);
			}
		}
	}
    /*for (int i=0; i<n; i++){
        for (int j=0; j<4; j++){
            cout << a[i][j].first << " " << a[i][j].second << " " << b[i][j].first << " " << b[i][j].second << "\n";
        }
    }*/
	return;
}

ll simulate(int x, int z){
	ll y = z;
	while (y < s[0] && x != n){
		int i = 0;
		while (y+a[x][i+1].second < s[0]) i++;
        y += a[x][i].second;
		x = a[x][i].first;
        //cout << x << " " << y << "\n";
	}
    //cout << "a\n";
	while (x != n){
        int i = 0;
		while (b[x][i+1].first != n) i++;
        y += b[x][i].second;
		x = b[x][i].first;
        //cout << x << " " << y << "\n";
	}
	return y;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...