답안 #990321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990321 2024-05-30T08:02:08 Z alex_2008 Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
vector <vector<int>> G;
vector <int> order;
int dfs(int v, int p) {
	order.push_back(v);
	for (auto it : G[v]) {
		if (it == p) continue;
		dfs(it, v);
	}
}
int findEgg(int N, vector < pair < int, int > > bridges) {
	order.clear();
	G.clear();
	G.resize(N + 1);
	for (auto &it : bridges) {
		G[it.first].push_back(it.second);
		G[it.second].push_back(it.first);
	}
	dfs(1, -1);
	int ans = n - 1;
	int l = 0, r = n - 2;
	while (l <= r) {
		vector <int> w;
		int mid = (l + r) / 2;
		for (int i = 0; i <= mid; i++) {
			w.push_back(order[i]);
		}
		if (query(w)) {
			ans = mid;
			r = mid - 1;
		}
	}
	return order[ans];
}

Compilation message

eastereggs.cpp: In function 'int dfs(int, int)':
eastereggs.cpp:12:1: warning: no return statement in function returning non-void [-Wreturn-type]
   12 | }
      | ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:12: error: 'n' was not declared in this scope
   22 |  int ans = n - 1;
      |            ^