#include "train.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
int n = (int)a.size();
int m = (int)u.size();
vector<int>ans(n,0);
vector<vector<int>>adj(n),adj2(n);
for (int i = 0;i<m;++i){
adj[u[i]].push_back(v[i]);
adj2[v[i]].push_back(u[i]);
}
vector<bool>visited(n,false),visited2(n,false);
function<void(int)>dfs = [&](int u){
visited[u] = true;
for (auto x:adj[u]){
if (!visited[x])dfs(x);
}
};
function<void(int)>dfs2 = [&](int u){
visited2[u] = true;
for (auto x:adj2[u]){
if (!visited2[x])dfs2(x);
}
};
for (int i = 0;i<n;++i){
if (!r[i])continue;
for (int j = 0;j<n;++j){
visited[i] = false;
visited2[i] = false;
}
for (auto x:adj[i])dfs(x);
for (auto x:adj2[i])dfs2(x);
if (visited[i]){
for (int j = 0;j<n;++j){
if (!visited2[j])continue;
ans[j] =1;
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
1236 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1620 KB |
Output is correct |
2 |
Correct |
18 ms |
1684 KB |
Output is correct |
3 |
Correct |
24 ms |
1688 KB |
Output is correct |
4 |
Correct |
24 ms |
1492 KB |
Output is correct |
5 |
Correct |
14 ms |
1492 KB |
Output is correct |
6 |
Incorrect |
14 ms |
1384 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
65 ms |
1312 KB |
3rd lines differ - on the 521st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1492 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
1236 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |