답안 #789936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
789936 2023-07-22T07:50:42 Z ymm 장난감 기차 (IOI17_train) C++17
0 / 100
896 ms 1532 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 = 5050;
vector<int> A[N];
int col[N];
bool charg[N];
int n, m;
int win[N];
bool vis[N];

bool dfs(int v)
{
	vis[v] = 1;
	if (charg[v])
		return win[v] = 1;
	bool ans = col[v]? 0: 1;
	for (int u : A[v]) {
		bool wu;
		if (vis[u])
			wu = win[u] == 1;
		else
			wu = dfs(u);
		if (col[v])
			ans |= wu;
		else
			ans &= wu;
	}
	win[v] = ans;
	return ans;
}

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);
	}
	vector<int> ans(n);
	Loop (i,0,n) {
		memset(win, -1, sizeof(win));
		memset(vis, 0, sizeof(vis));
		ans[i] = dfs(i);
	}
	return ans;
}

Compilation message

train.cpp: In function 'bool dfs(int)':
train.cpp:20:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   20 |   return win[v] = 1;
      |          ~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 1532 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1108 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 896 ms 1428 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -