답안 #149650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149650 2019-09-01T06:54:18 Z 욱방켜!! (twitch.tv/wookje)(#3584, kig9981, cheetose, jh05013) Bulb Game (FXCUP4_bulb) C++17
컴파일 오류
0 ms 0 KB
#include "bulb.h"

std::vector<int> L, R;
int dist[300000], mdist;

void dfs(int c, int v)
{
	mdist=max(mdist,v);
	if(L[c]>=0) {
		dist[L[c]]=dist[c]+1;
		dfs(L[c],v);
	}
	if(R[c]>=0) {
		dist[R[c]]=dist[c]+1;
		dfs(R[c],v+1);
	}
}

int FindWinner(int T, std::vector<int> L, std::vector<int> R){
	int N = L.size(), c, n;
	std::vector<int> temp;
	::L=L; ::R=R;
	for(c=0;c>=0;c=L[c]) {
		for(n=R[c];n>=0;n=L[n]);
		if(n==-2) {
			if(R[c]==-2) return 0;
			temp.push_back(R[c]);
		}
	}
	if(c==-2 || temp.size()>1) return 0;
	dfs(0,0);
	if(temp.empty() && mdist>1) return 1;
	for(c=temp[0];c>=0;c=L[c]) {
		for(n=R[c];n>=0;n=L[n]);
		if(n==-1) return 1;
	}
	return 0;
}

Compilation message

bulb.cpp: In function 'void dfs(int, int)':
bulb.cpp:8:8: error: 'max' was not declared in this scope
  mdist=max(mdist,v);
        ^~~
bulb.cpp:8:8: note: suggested alternative:
In file included from /usr/include/c++/7/vector:60:0,
                 from bulb.h:2,
                 from bulb.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   'std::max'
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:20:6: warning: unused variable 'N' [-Wunused-variable]
  int N = L.size(), c, n;
      ^