제출 #98898

#제출 시각아이디문제언어결과실행 시간메모리
98898square1001장난감 기차 (IOI17_train)C++14
10 / 100
2052 ms1024 KiB
#include "train.h"
#include <vector>
#include <algorithm>
using namespace std;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size(), m = u.size();
	vector<vector<int> > g(n);
	for (int i = 0; i < m; ++i) {
		g[u[i]].push_back(v[i]);
	}
	vector<int> dp(n, n);
	for (int i = 0; i < n * n; ++i) {
		vector<int> ndp(n);
		for (int j = 0; j < n; ++j) {
			if (a[j] == 1) {
				ndp[j] = 0;
				for (int k : g[j]) {
					ndp[j] = max(ndp[j], dp[k] - 1);
				}
			}
			else {
				ndp[j] = n;
				for (int k : g[j]) {
					ndp[j] = min(ndp[j], dp[k] > 0 ? dp[k] - 1 : 0);
				}
			}
			if (r[j] == 1 && ndp[j] > 0) {
				ndp[j] = n;
			}
		}
		dp = ndp;
	}
	vector<int> ans(n);
	for (int i = 0; i < n; ++i) {
		ans[i] = (dp[i] > 0 ? 1 : 0);
	}
	return ans;
}
#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...