답안 #279639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
279639 2020-08-22T08:53:26 Z MKutayBozkurt Easter Eggs (info1cup17_eastereggs) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int>> v;
vector<int> ans;

void dfs(int i, int last = -1) {
	ans.emplace_back(i);
	for (auto node : v[i]) {
		if (last == node) continue;
		dfs(node, i);
	}
}

int findEgg(int n, vector<pair<int, int>> bridges) {
	v = vector<vector<int>>(n + 1);
	for (auto node : bridges) {
		v[node.first].emplace_back(node.second);
		v[node.second].emplace_back(node.first);
	}
	dfs(1);
	int l = 0, r = n - 1;
	while (l <= r) {
		int m = (l + r) / 2;
		if (query(vector<int>(ans.begin(), ans.begin() + mid + 1))) r = mid;
		else l = mid;
	}
	return ans[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:26:52: error: 'mid' was not declared in this scope
   26 |   if (query(vector<int>(ans.begin(), ans.begin() + mid + 1))) r = mid;
      |                                                    ^~~
eastereggs.cpp:25:7: warning: unused variable 'm' [-Wunused-variable]
   25 |   int m = (l + r) / 2;
      |       ^