제출 #425696

#제출 시각아이디문제언어결과실행 시간메모리
425696TangentToy Train (IOI17_train)C++17
5 / 100
10 ms1028 KiB
#include "train.h"
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;

#define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int n = a.size();
	vvii adj(n);
	rep(i, u.size()) {
		adj[u[i]].emplace_back(v[i]);
	}

	vii res(n, -1);
	res[n - 1] = r[n - 1];
	fford(i, n - 2, -1) {
		if (a[i]) {
			res[i] = 0;
			forin(j, adj[i]) {
				if (j == i) {
					res[i] = max(res[i], r[i]);
				} else {
					res[i] = max(res[i], res[i + 1]);
				}
			}
		} else {
			res[i] = 1;
			forin(j, adj[i]) {
				if (j == i) {
					res[i] = min(res[i], r[i]);
				} else {
					res[i] = min(res[i], res[i + 1]);
				}
			}
		}
	}
	return res;
}
#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...