#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3+10;
vector<int>adj[N],R,A;
unordered_set<int>st;
int cnt[N];
int n,m;
bool vis[N],ispar[N];
bool dfs(int i,int pre){
if(vis[i])
return 0;
ispar[i] = 1;vis[i] = 1;
cnt[i] = cnt[pre]+R[i];
bool ret = 0;
for(auto x:adj[i]){
ret |= dfs(x,i);
if(!ispar[x])
continue;
if(cnt[i]-cnt[x]+R[x]!=0)ret = 1;
assert(cnt[i]-cnt[x]+R[x]>=0);
}
ispar[i] = 0;
return ret;
}
vector<int>ans,cmp;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
n = a.size(),m = u.size();
A = a;R = r;
for(int i=0;i<m;i++)
adj[u[i]].push_back(v[i]);
for(int i=0;i<n;i++){
ans.push_back(dfs(i,n+1));
memset(vis,0,sizeof(vis));
memset(cnt,0,sizeof(cnt));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
311 ms |
1188 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
227 ms |
1488 KB |
Output is correct |
2 |
Correct |
223 ms |
1656 KB |
Output is correct |
3 |
Correct |
232 ms |
1692 KB |
Output is correct |
4 |
Correct |
1523 ms |
1756 KB |
Output is correct |
5 |
Correct |
1122 ms |
1568 KB |
Output is correct |
6 |
Correct |
729 ms |
1448 KB |
Output is correct |
7 |
Correct |
673 ms |
1328 KB |
Output is correct |
8 |
Incorrect |
356 ms |
1316 KB |
3rd lines differ - on the 27th token, expected: '1', found: '0' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1117 ms |
1236 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1677 ms |
1400 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
311 ms |
1188 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |