#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 3e5 + 5;
vector < int > Left, Right;
int N;
int FindWinner(int T, std :: vector < int > L, std :: vector < int > R)
{
Left = L;
Right = R;
N = (int)L.size();
int Node = 0;
while(Node >= 0)
Node = Left[Node];
if(Node == -2) /// The leftest bulb is blue;
return 0;
for(int i = 0; i < N; ++i)
{
bool Red = true;
bool Ok = false;
Node = 0;
while(Node >= 0)
{
if(Node == i)
{
if(Left[Node] >= 0)
Ok = true;
}
else
{
if(Right[Node] >= 0)
Ok = true;
}
int Go = (Node == i) ? Left[Node] : Right[Node];
while(Go >= 0)
Go = (Go == i) ? Right[Node] : Left[Node];
if(Go == -2)
{
Red = false;
break;
}
if(Node == i) /// The "i" - th swithch is pressed;
Node = Right[Node];
else Node = Left[Node];
}
if(Red && (!Ok || Node == -1)) /// One red bulb is turned on;
return 1;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
376 KB |
Output is correct |
2 |
Execution timed out |
1039 ms |
376 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1064 ms |
256 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1064 ms |
256 KB |
Time limit exceeded |