#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]];
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 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
3 ms |
852 KB |
Output is correct |
4 |
Correct |
3 ms |
896 KB |
Output is correct |
5 |
Correct |
4 ms |
852 KB |
Output is correct |
6 |
Correct |
4 ms |
852 KB |
Output is correct |
7 |
Correct |
3 ms |
852 KB |
Output is correct |
8 |
Correct |
3 ms |
852 KB |
Output is correct |
9 |
Correct |
3 ms |
824 KB |
Output is correct |
10 |
Correct |
3 ms |
852 KB |
Output is correct |
11 |
Correct |
4 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2087 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2041 ms |
980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2062 ms |
852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
980 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 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
3 ms |
852 KB |
Output is correct |
4 |
Correct |
3 ms |
896 KB |
Output is correct |
5 |
Correct |
4 ms |
852 KB |
Output is correct |
6 |
Correct |
4 ms |
852 KB |
Output is correct |
7 |
Correct |
3 ms |
852 KB |
Output is correct |
8 |
Correct |
3 ms |
852 KB |
Output is correct |
9 |
Correct |
3 ms |
824 KB |
Output is correct |
10 |
Correct |
3 ms |
852 KB |
Output is correct |
11 |
Correct |
4 ms |
852 KB |
Output is correct |
12 |
Execution timed out |
2087 ms |
212 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |