#include "train.h"
#include<bits/stdc++.h>
using namespace std;
int n, m;
vector<int> aa, rr;
int solve(vector<int> adj[], int pos, int cur)
{
int csz = adj[pos].size();
int nxt;
if(csz == 1)
{
if(adj[pos][0] == pos)
return rr[adj[pos][0]] & aa[adj[pos][0]];
else
nxt = adj[pos][0];
}
else
{
if(rr[pos])
{
if(aa[pos])
return 1;
else
nxt = max(adj[pos][0], adj[pos][1]);
}
else
{
if(!aa[pos])
return 0;
else
nxt = max(adj[pos][0], adj[pos][1]);
}
}
return solve(adj, nxt, cur + 1);
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size(), m = u.size();
aa = a;
rr = r;
vector<int> adj[n], ans(n);
for(int i=0;i<m;i++)
adj[u[i]].push_back(v[i]);
for(int i=0;i<n;i++)
{
ans[i] = solve(adj, i, 0);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
724 KB |
Output is correct |
2 |
Incorrect |
3 ms |
852 KB |
3rd lines differ - on the 4997th token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2084 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2069 ms |
980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1000 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
724 KB |
Output is correct |
2 |
Incorrect |
3 ms |
852 KB |
3rd lines differ - on the 4997th token, expected: '1', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |