#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
const int R = -1;
const int B = -2;
typedef pair<int, int> p;
vector<int> g[303030]; //R -1 B -2
p color[303030];
void dfs(int v){
if(g[v][0] < 0){
color[v].first = g[v][0];
}else{
dfs(g[v][0]);
color[v].first = color[g[v][0]].first;
}
if(g[v][1] < 0){
color[v].second = g[v][1];
}else{
dfs(g[v][1]);
color[v].second = color[g[v][1]].first;
}
}
bool chk(int v){
//cout << v << " " << color[v].first << " " << color[v].second << "\n";
if(color[v].first == R && color[v].second == R) return 1;
if(color[v].first == B && color[v].second == B) return 0;
if(color[v].first == R && color[v].second == B) return chk(g[v][1]);
return 1;
}
int FindWinner(int T, std::vector<int> l, std::vector<int> r){
int n = l.size();
for(int i=0; i<n; i++){
g[i].push_back(l[i]);
g[i].push_back(r[i]);
}
dfs(0);
if(color[0].first == B){
return 0;
}
return chk(0);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7544 KB |
Output is correct |
2 |
Correct |
8 ms |
7416 KB |
Output is correct |
3 |
Correct |
9 ms |
7544 KB |
Output is correct |
4 |
Correct |
9 ms |
7516 KB |
Output is correct |
5 |
Correct |
8 ms |
7544 KB |
Output is correct |
6 |
Incorrect |
9 ms |
7416 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7388 KB |
Output is correct |
2 |
Correct |
8 ms |
7416 KB |
Output is correct |
3 |
Correct |
9 ms |
7544 KB |
Output is correct |
4 |
Correct |
8 ms |
7416 KB |
Output is correct |
5 |
Correct |
9 ms |
7544 KB |
Output is correct |
6 |
Correct |
9 ms |
7516 KB |
Output is correct |
7 |
Correct |
8 ms |
7544 KB |
Output is correct |
8 |
Incorrect |
9 ms |
7416 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7388 KB |
Output is correct |
2 |
Correct |
8 ms |
7416 KB |
Output is correct |
3 |
Correct |
9 ms |
7544 KB |
Output is correct |
4 |
Correct |
8 ms |
7416 KB |
Output is correct |
5 |
Correct |
9 ms |
7544 KB |
Output is correct |
6 |
Correct |
9 ms |
7516 KB |
Output is correct |
7 |
Correct |
8 ms |
7544 KB |
Output is correct |
8 |
Incorrect |
9 ms |
7416 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |