답안 #1076878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076878 2024-08-26T17:40:55 Z Gray 장난감 기차 (IOI17_train) C++17
5 / 100
5 ms 2652 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

#define ll int
#define ff first
#define ss second
#define ln "\n"
#define ld long double

vector<ll> are;
vector<ll> isc;
vector<vector<ll>> A;
ll n, m;

void dfs(ll u, vector<ll> &dp){
	dp[u]=-2;
	bool spec=0;
	for (auto v:A[u]){
		if (v==u) spec=1;
		if (dp[v]==-1) {dfs(v, dp); dp[u]=dp[v];}
	}
	if (spec){
		if (isc[u] and (are[u] or A[u].size()==1)){
			dp[u]=1;
		}else{
			if (!isc[u] and !are[u]) dp[u]=0;
			else if (dp[u]==-2) dp[u]=0;
		}
	}
	// if (dp[u]==-2) dp[u]=0;
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n=a.size(); m=v.size();
	isc=r; are=a;
	A.clear(); A.resize(n);
	for (ll i=0; i<m; i++){
		A[u[i]].push_back(v[i]);
	}
	vector<int> dp(n, -1);
	for (ll i=0; i<n; i++){
		if (dp[i]==-1) dfs(i, dp);
		assert(dp[i]!=-2);
	}
	return dp;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1368 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 860 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 3 ms 856 KB Output is correct
11 Correct 2 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 2396 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 2392 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 2652 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1368 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 860 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 3 ms 856 KB Output is correct
11 Correct 2 ms 856 KB Output is correct
12 Runtime error 1 ms 344 KB Execution killed with signal 6
13 Halted 0 ms 0 KB -