답안 #149580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149580 2019-09-01T06:47:04 Z 갓띵건(#3694, gs18103, sjimed, gs18065) Bulb Game (FXCUP4_bulb) C++17
11 / 100
2 ms 376 KB
#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 ans[300010];

int dfs(int x) {
	if(x < 0) return x;

	dfs(l[x]);
	dfs(r[x]);

	change[x] = inf;
	
	if(l[x] == -1) {
		change[x] = 0;
	}
	if(r[x] == -1) {
		change[x] = min(change[x], 1);
	}
	if(l[x] >= 0) {
		change[x] = min(change[x], change[l[x]]);
	}
	if(r[x] >= 0) {
		change[x] = min(change[x], change[r[x]]+1);
	}

	int a[2] = {0, 1};
	if(l[x] >= 0) a[0] += ans[l[x]], a[1] += change[l[x]];
	if(r[x] >= 0) a[1] += ans[r[x]], a[0] += change[r[x]]; 
	if(l[x] == -2 || r[x] == -2) {
		ans[x] = inf;
	}
	else ans[x] = min({inf, a[0], a[1]});
}

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 << ans[i] << endl;
	//}

	if(ans[0] <= 1) return 1;
	else return 0;
}

Compilation message

bulb.cpp: In function 'int dfs(int)':
bulb.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -