이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "train.h"
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
#define pb push_back
#define popb pop_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
const int nax = 5004;
const int MOD = 1e9 + 7;
int n, m;
vi adj[nax];
int vis[nax];
int A[nax], C[nax];
int dfs(int x, int dep )
{
if(C[x] == 1)
dep = n;
if(dep == 0)
return 0;
vis[x] = 1;
int ans = -1;
for(auto e: adj[x])
{
int rep;
if(vis[e])
rep = 1;
else
rep = dfs(e, dep - 1);
if(ans == -1)
ans = rep;
else
{
if(A[x])
if(rep == 1)
ans = 1;
if(!A[x])
if(rep == 0)
ans = 0;
}
}
vis[x] = 0 ;
return ans;
}
vi who_wins(vi a, vi r, vi u, vi v)
{
n = a.size();
m = u.size();
for(int i = 0 ; i < n; i++)
{
A[i] = a[i];
C[i ] = r[i];
}
for(int i = 0 ; i < m; i ++)
{
adj[u[i]].pb(v[i]);
}
vi ans(n, 0);
for(int i = 0 ; i < n; i ++)
{
ans[i] = dfs(i, n);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |