#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
const int Nmax = 3e5 + 5;
bool bad = 0;
int v1[Nmax], v2[Nmax];
void dfs(int node, vector<int> &L, vector<int> &R, int e1, int e2, int e3)
{
if(node == -1)
return;
if(node == -2)
{
if(e1 == -1) bad = 1;
else
if(e2 == -1) v1[e1]++;
else
if(e3 == -1)
{
v2[e1]++;
v2[e2]++;
}
return;
}
dfs(L[node], L, R, e1, e2, e3);
if(e1 == -1) e1 = node;
else if(e2 == -1) e2 = node;
else if(e3 == -1) e3 = node;
dfs(R[node], L, R, e1, e2, e3);
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R)
{
int n = L.size();
int e1 = -1, e2 = -1, e3 = -1;
dfs(0, L, R, e1, e2, e3);
int i;
if(bad) return 0;
int total = 0;
for(i=0; i<n; ++i) total += v1[i];
for(i=0; i<n; ++i)
{
if(v2[i]) continue;
if(total - v1[i] > 0) continue;
//cerr << i << '\n';
return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
296 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
296 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |