답안 #128625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128625 2019-07-11T07:45:57 Z sheyasutaka Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include "grader.h"


#include <vector>
using std::vector;
using std:pair;
typedef pair<int, int> P;

vector<int> g[600];
vector<int> euler;

void dfs (int v, int p) {
	euler.push_back(v);

	for (int u : g[v]) {
		if (u == p) continue;
		dfs(u, v);
	}
}

int findEgg (int N, P bridges) {
	int i, j;

	for (i = 0; i < g.size(); i++) {
		g[i].clear();
	}
	euler.clear();

	for (i = 0; i < N - 1; i++) {
		g[bridges[i].first - 1].push_back(bridges[i].second - 1);
		g[bridges[i].second - 1].push_back(bridges[i].first - 1);
	}

	dfs(0, N);

	int l = 0, r = N;
	while (l + 1 < r) {
		int med = (l + r) / 2;

		vector<int> v;
		for (i = 0; i < med; i++) {
			v.push_back(euler[i] + 1);
		}
		if (query(v)) {
			r = med;
		} else {
			l = med;
		}
	}
	return euler[l] + 1;
}

Compilation message

eastereggs.cpp:7:10: error: found ':' in nested-name-specifier, expected '::'
 using std:pair;
          ^
eastereggs.cpp: In function 'int findEgg(int, P)':
eastereggs.cpp:25:20: error: request for member 'size' in 'g', which is of non-class type 'std::vector<int> [600]'
  for (i = 0; i < g.size(); i++) {
                    ^~~~
eastereggs.cpp:31:12: error: no match for 'operator[]' (operand types are 'P {aka std::pair<int, int>}' and 'int')
   g[bridges[i].first - 1].push_back(bridges[i].second - 1);
            ^
eastereggs.cpp:31:44: error: no match for 'operator[]' (operand types are 'P {aka std::pair<int, int>}' and 'int')
   g[bridges[i].first - 1].push_back(bridges[i].second - 1);
                                            ^
eastereggs.cpp:32:12: error: no match for 'operator[]' (operand types are 'P {aka std::pair<int, int>}' and 'int')
   g[bridges[i].second - 1].push_back(bridges[i].first - 1);
            ^
eastereggs.cpp:32:45: error: no match for 'operator[]' (operand types are 'P {aka std::pair<int, int>}' and 'int')
   g[bridges[i].second - 1].push_back(bridges[i].first - 1);
                                             ^
eastereggs.cpp:23:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^