이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define REP(i,n) for(int i = 0;i < n;i++)
const int N = 5001;
bool reach[N][N];
bool reach1[N][N];
int n,m;
vector<int> adj[N];
vector<int> adj1[N];
int source = 0;
void dfs(int u){
for(int v:adj[u]){
if(reach[source][v])continue;
reach[source][v] = 1;
dfs(v);
}
}
void dfs1(int u){
for(int v:adj1[u]){
if(reach1[source][v])continue;
reach1[source][v] = 1;
dfs1(v);
}
}
vector<int> who_wins(vector<int> a, vector<int> r,vector<int> u, vector<int> v) {
n = a.size();
m = u.size();
REP(i,m){
adj[u[i]].pb(v[i]);
if(!r[u[i]] and !r[v[i]]){
adj1[u[i]].pb(v[i]);
}
}
while(source < n){
dfs(source);
dfs1(source);
source++;
}
vector<int> ans;
REP(i,n){
bool done = 0;
REP(j,n){
if(r[j])continue;
if(reach[i][j] and reach1[j][j]){
done = 1;
}
}
ans.pb(!done);
}
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... |