#include "bulb.h"
int n;
std::vector <int> Left, Right;
int check_which_bulb(std::vector <bool> &bt)
{
int ans = 0;
while(ans >= 0)
{
if (bt[ans])
ans = Right[ans];
else ans = Left[ans];
}
return ans;
}
bool redhub(std::vector <bool> bt)
{
for (int i = 0; i<n; i++)
{
if (bt[i])
continue;
else
{
bt[i] = true;
int u = check_which_bulb(bt);
if (u == -2)
return false;
bt[i] = false;
}
}
return true;
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R)
{
Left = L, Right = R;
int N = L.size();
n = N;
std::vector <bool> on (N, false);
int start = check_which_bulb(on);
//printf("%d\n", start);
if (start == -2)
return 0;
for (int i = 0; i<N; i++)
{
on[i] = true;
if (redhub(on))
{
//printf("Redhub found %d\n",i);
return 1;
}
on[i] = false;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
9 ms |
312 KB |
Output is correct |
21 |
Correct |
11 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
348 KB |
Output is correct |
23 |
Correct |
8 ms |
256 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
9 ms |
312 KB |
Output is correct |
21 |
Correct |
11 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
348 KB |
Output is correct |
23 |
Correct |
8 ms |
256 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
5 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
252 KB |
Output is correct |
27 |
Correct |
73 ms |
7440 KB |
Output is correct |
28 |
Correct |
87 ms |
7416 KB |
Output is correct |
29 |
Execution timed out |
1080 ms |
7416 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |