답안 #790015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790015 2023-07-22T09:14:30 Z ymm 장난감 기차 (IOI17_train) C++17
0 / 100
1014 ms 1228 KB
#include "train.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (long long x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<ll,ll> pll;
using namespace std;

const int N = 5032;
vector<int> A[N];
bool vis[N];
bool reach_self[N];
bool col[N], charg[N];
int n, m;

bool dfs(int v, int rt)
{
	vis[v] = 1;
	for (int u : A[v]) {
		if (charg[u])
			continue;
		if (u == rt)
			return 1;
		if (vis[u])
			continue;
		if (dfs(u, rt))
			return 1;
	}
	return 0;
}

void dfs2(int v)
{
	vis[v] = 1;
	for (int u : A[v]) {
		if (!vis[u])
			dfs2(u);
	}
}

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> V, std::vector<int> U) {
	n = a.size();
	m = V.size();
	Loop (i,0,n) {
		col[i] = a[i];
		charg[i] = r[i];
	}
	Loop (i,0,m) {
		int v = V[i], u = U[i];
		A[v].push_back(u);
	}
	Loop (i,0,n) {
		memset(vis, 0, sizeof(vis));
		reach_self[i] = dfs(i, i);
	}
	vector<int> ans(n);
	Loop (i,0,n) {
		memset(vis, 0, sizeof(vis));
		dfs2(i);
		Loop (i,0,n)
			ans[i] |= vis[i] && reach_self[i];
		ans[i] = !ans[i];
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 160 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 246 ms 1228 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 603 ms 952 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1014 ms 1156 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 160 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -