Submission #406888

#TimeUsernameProblemLanguageResultExecution timeMemory
406888cheissmartToy Train (IOI17_train)C++14
5 / 100
9 ms992 KiB
#include "train.h"
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
	cerr << to_string(h);
	if(sizeof ...(t)) cerr << ", ";
	DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7, N = 5005;

vi G[N];

vi who_wins(vi a, vi r, vi u, vi v) {
	int n = a.size(), m = u.size();
	assert(u.size() == v.size());

	for(int i = 0; i < m; i++)
		G[u[i]].PB(v[i]);

	vi dp(n);
	for(int i = n - 1; i >= 0; i--) {
		bool has_nxt = count(ALL(G[i]), i + 1);
		bool has_loop = count(ALL(G[i]), i);
		if(has_nxt == 0) {
			dp[i] = r[i];
		} else {
			if(has_loop && a[i] == r[i]) dp[i] = a[i];
			else dp[i] = dp[i + 1];
		}
	}
	return dp;
}
#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...