#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<pair<ll, ll>> edge;
vector<vector<ll>> A;
ll n, m;
void dfs(ll u, vector<ll> &vis, vector<ll> &dp, vector<ll> &cnt, ll top){
cnt[u]=top;
if (isc[u]) top++;
vis[u]=1;
dp[u]=0;
for (auto i:A[u]){
ll v = edge[i].ff^edge[i].ss^u;
if (vis[v]==1) {
if (cnt[v]==top) dp[u]=1;
continue;
}else if (vis[v]==0){
dfs(v, vis, dp, cnt, top);
}
dp[u]|=dp[v];
}
vis[u]=2;
}
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);
edge.clear(); edge.resize(m);
for (ll i=0; i<m; i++){
edge[i] = {u[i], v[i]};
A[u[i]].push_back(i);
}
vector<ll> vis(n), dp(n), cnt(n);
for (ll i=0; i<n; i++){
if (!vis[i]){
dfs(i, vis, dp, cnt, 0);
}
}
for (ll i=0; i<n; i++) dp[i]=!dp[i];
return dp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1368 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1884 KB |
Output is correct |
2 |
Correct |
4 ms |
1860 KB |
Output is correct |
3 |
Correct |
5 ms |
1628 KB |
Output is correct |
4 |
Incorrect |
5 ms |
1856 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1372 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1372 KB |
3rd lines differ - on the 458th token, expected: '0', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1624 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1368 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |