#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);
vector<vector<int>>adj(n);
for (int i = 0;i<m;++i){
adj[u[i]].push_back(v[i]);
}
vector<int>visited(n,-1);
vector<int>cnt(n,0);
for (int i = 0;i<n;++i){
function<int(int,int)>dfs = [&](int u,int got){
if (visited[u] == i){
if (got)return 1;
return 0;
}
else if (visited[u]!=-1){
return cnt[u];
}
visited[u] = i;
int ans = 0;
for (auto x:adj[u]){
ans|=dfs(x,(got|(r[x] == 1)));
}
return cnt[u] = ans;
};
if (visited[i] != -1){
ans[i] = cnt[i];
}
else{
ans[i] = dfs(i,r[i]);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 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 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1364 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1108 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1280 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1236 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |