제출 #390045

#제출 시각아이디문제언어결과실행 시간메모리
390045Keshi장난감 기차 (IOI17_train)C++17
11 / 100
1751 ms136352 KiB
//In the name of God
#include <bits/stdc++.h>
#include "train.h"
using namespace std;

typedef int ll;
typedef pair<ll, ll> pll;

const ll maxn = 5100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()

ll n, m, c[maxn], t;
bool del[maxn], ok[maxn], vis[maxn], w[maxn], okk[maxn];
bool sub1 = 1, sub3 = 1, sub4 = 1;
vector<ll> vec, g[maxn], gp[maxn], com[maxn];
bitset<maxn> can[maxn];

void dfs(ll p, ll v){
	vis[v] = 1;
	if(del[v]) return;
	for(ll u : g[v]){
		can[p][u] = 1;
		if(!vis[u]) dfs(p, u);
	}
	vec.pb(v);
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> v, vector<int> u){
	n = Sz(a);
	m = Sz(v);
	for(ll i = 0; i < m; i++){
		if(u[i] != v[i] && u[i] != v[i] + 1) sub1 = 0;
		g[v[i]].pb(u[i]);
		gp[u[i]].pb(v[i]);
	}
	vector<int> res(n);
	for(ll i = 0; i < n; i++){
		if(a[i]) sub4 = 0;
		else sub3 = 0;
	}
	for(ll i = 0; i < n; i++){
		if(sub3) ok[i] = r[i];
		else ok[i] = 1;
		if(sub4) del[i] = r[i];
	}
	for(ll i = 0; i < n; i++){
		fill(vis, vis + n + 1, 0);
		dfs(i, i);
	}
	for(ll i = 0; i < n; i++){
		if(del[i]) continue;
		for(ll j = 0; j < n; j++){
			if(ok[j] && can[i][j] && can[j][i]) w[i] = 1;
		}
	}
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < n; j++){
			if(can[i][j] && w[j]) res[i] = 1;
		}
		if(sub4) 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...