이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bulb.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed;cout.precision(a)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n;
vector<int> l, r;
int change[300010];
int c[300010];
int dfs(int x) {
if(x < 0) return x;
c[x] = dfs(l[x]);
if(l[x] >= 0) change[x] = change[l[x]];
if(change[x] > 1 || c[x] == -2) {
c[x] = dfs(r[x]);
if(r[x] >= 0) change[x] = change[r[x]];
change[x]++;
}
else dfs(r[x]);
return c[x];
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
n = L.size();
l = L;
r = R;
dfs(0);
//for(int i=0; i<n; i++) {
//cout << c[i] << " " << change[i] << endl;
//}
if(c[0] == -2) return 0;
int cnt = 0;
for(int i=0; i>=0; i = l[i]) {
if(r[i] == -2) return 0;
if(r[i] == -1) continue;
if(c[r[i]] == -2) return 0;
cnt += change[r[i]];
//cout << "!" << r[i] << " " << change[r[i]] << endl;
}
if(cnt <= 1) return 1;
else return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |