#include "train.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (long long x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<ll,ll> pll;
using namespace std;
const int N = 5032;
vector<int> A[N];
bool vis[N];
bool reach_self[N];
bool col[N], charg[N];
int n, m;
bool dfs(int v, int rt)
{
vis[v] = 1;
for (int u : A[v]) {
if (charg[u])
continue;
if (u == rt)
return 1;
if (vis[u])
continue;
if (dfs(u, rt))
return 1;
}
return 0;
}
void dfs2(int v)
{
vis[v] = 1;
for (int u : A[v]) {
if (!vis[u])
dfs2(u);
}
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> V, std::vector<int> U) {
n = a.size();
m = V.size();
Loop (i,0,n) {
col[i] = a[i];
charg[i] = r[i];
}
Loop (i,0,m) {
int v = V[i], u = U[i];
A[v].push_back(u);
}
Loop (i,0,n) {
if (charg[i])
continue;
memset(vis, 0, sizeof(vis));
reach_self[i] = dfs(i, i);
}
vector<int> ans(n);
Loop (i,0,n) {
memset(vis, 0, sizeof(vis));
dfs2(i);
Loop (i,0,n)
ans[i] |= reach_self[i];
ans[i] = !ans[i];
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
149 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
1228 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
549 ms |
948 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
992 ms |
1152 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
149 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |