답안 #319075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319075 2020-11-03T20:54:24 Z NachoLibre Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

// int query(vector<int> islads);

vector<int> v[513], ve;
int bo[513], c, a;

void sgd(int dg, int op) {
	ve.push_back(dg);
	if(bo[dg]) ++a;
	if(a == c / 2) return;
	for(int i = 0; i < v[dg].size(); ++i) {
		if(v[dg][i] != op) {
			sgd(v[dg][i], dg);
			if(a == c / 2) return;
		}
	}
}

int findEgg(int n, vector<pair<int, int> > brd) {
	for(int i = 1; i <= n; ++i) {
		v[i].clear();
		bo[i] = 1;
	}
	for(int i = 0; i < n - 1; ++i) {
		v[brd[i].first].push_back(brd[i].second);
		v[brd[i].second].push_back(brd[i].first);
	}
	c = n;
	while(c > 1) {
		ve.clear(); a = 0;
		sgd(1, 0);
		if(query(ve)) {
			for(int i = 0; i < ve.size(); ++i) {
				if(bo[ve[i]]) bo[ve[i]] = 2;
			}
			for(int i = 1; i <= n; ++i) {
				if(bo[i] != 2) bo[i] = 0;
			}
			for(int i = 1; i <= n; ++i) {
				if(bo[i] == 2) bo[i] = 1;
			}
		} else {
			for(int i = 0; i < ve.size(); ++i) {
				bo[ve[i]] = 0;
			}
		}
	}
	for(int i = 1; i <= n; ++i) {
		if(bo[i]) return i;
	}
}
/*
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	return 0;
}
*/

Compilation message

eastereggs.cpp: In function 'void sgd(int, int)':
eastereggs.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i = 0; i < v[dg].size(); ++i) {
      |                 ~~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:34:6: error: 'query' was not declared in this scope
   34 |   if(query(ve)) {
      |      ^~~~~
eastereggs.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |    for(int i = 0; i < ve.size(); ++i) {
      |                   ~~^~~~~~~~~~~
eastereggs.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |    for(int i = 0; i < ve.size(); ++i) {
      |                   ~~^~~~~~~~~~~
eastereggs.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^