#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ke[5001],ke2[5001],ke3[5001],d;
int n,m,vis[5001],p[5001],sz[5001],ch[5001];
stack <int> st;
queue <int> q;
void dfs(int u){
vis[u]=1;
for (int v:ke[u])
if (!vis[v])
dfs(v);
st.push(u);
}
void dfs2(int u){
sz[p[u]]++;
vis[u]=1;
for (int v:ke2[u])
if (!vis[v]){
p[v]=p[u];
dfs2(v);
}
}
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v){
n=a.size(),m=u.size();
for (int i=0;i<m;i++){
if (u[i]==v[i])
ch[u[i]]=1;
ke3[v[i]].push_back(u[i]);
if (r[u[i]]||r[v[i]])
continue;
ke[u[i]].push_back(v[i]);
ke2[v[i]].push_back(u[i]);
}
for (int i=0;i<n;i++)
if (!vis[i])
dfs(i);
iota(p,p+n,0);
memset(vis,0,sizeof(vis));
while (!st.empty()){
int u=st.top();
st.pop();
if (!vis[u])
dfs2(u);
}
d.assign(n,1);
for (int i=0;i<n;i++){
if (!r[i]&&(sz[p[i]]>1||ch[i])){
d[i]=0;
q.push(i);
}
}
while (!q.empty()){
int u=q.front();
q.pop();
for (int v:ke3[u])
if (d[v]){
d[v]=0;
q.push(v);
}
}
return d;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1372 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1880 KB |
Output is correct |
2 |
Correct |
6 ms |
1884 KB |
Output is correct |
3 |
Correct |
5 ms |
1884 KB |
Output is correct |
4 |
Incorrect |
6 ms |
1628 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1372 KB |
Output is correct |
2 |
Correct |
6 ms |
1856 KB |
Output is correct |
3 |
Correct |
7 ms |
2036 KB |
Output is correct |
4 |
Correct |
6 ms |
1628 KB |
Output is correct |
5 |
Correct |
7 ms |
2152 KB |
Output is correct |
6 |
Correct |
6 ms |
2096 KB |
Output is correct |
7 |
Correct |
6 ms |
1884 KB |
Output is correct |
8 |
Correct |
6 ms |
1884 KB |
Output is correct |
9 |
Correct |
5 ms |
1628 KB |
Output is correct |
10 |
Correct |
6 ms |
1628 KB |
Output is correct |
11 |
Correct |
5 ms |
1628 KB |
Output is correct |
12 |
Correct |
6 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2140 KB |
Output is correct |
14 |
Correct |
8 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1884 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1372 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |