# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
211692 | thebes | Bulb Game (FXCUP4_bulb) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#inlcude "bulb.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
const int MN = 3e5+5;
int N, i, res[MN], w[MN][2], vs[MN], f, f2, f3, f4;
pii ed[MN];
int acc(int n){
if(n<0) return 0;
if(res[n]) return res[n];
res[n]=ed[n].first<0?ed[n].first:acc(ed[n].first);
return res[n];
}
void solve(int n,int b){
if(n<0) return;
solve(ed[n].first,b);
solve(ed[n].second,0);
w[n][0]=ed[n].first<0?ed[n].first:w[ed[n].first][0];
if(b){
if(ed[n].first>=0) w[n][1]|=w[ed[n].first][1];
if(ed[n].second>=0){
w[n][1]|=(w[ed[n].second][0]==-1);
if(w[n][0]==-1) w[n][1]|=w[ed[n].second][1];
}