답안 #243033

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243033 2020-06-30T08:02:10 Z HachiMinh Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef vector<int> vct;
vct HMS[600],USS;
void dfs(int u,int pa)
{
	USS.pb(u);
	for(int i=0;i<HMS[u].size();i++)
	{
		int d=HMS[u][i];
		if(d!=pa)
		{
			dfs(d,u);
		}
	}
}
int check(int mid)
{
	vector<int> KMS;
	for(int i=0;i<=mid;i++)
	{
		KMS.pb(USS[i]);
	}
	return query(KMS);
}
int findEgg(int N,vector<pair<int,int> >bridges)
{
	USS.clear();
	for(int i=0;i<N-1;i++)
	{
		int u=bridges[i].fi,v=bridges[i].se;
		HMS[u].pb(v);
		HMS[v].pb(u);
	}
	dfs(1,0);
	int l=0,r=USS.size()-1;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	for(int i=0;i<n+7;i++) HMS[i].clear();
	return USS[l];
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<HMS[u].size();i++)
              ~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:49:16: error: 'n' was not declared in this scope
  for(int i=0;i<n+7;i++) HMS[i].clear();
                ^