답안 #332565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332565 2020-12-02T21:42:49 Z codemaster111 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
4 ms 768 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
#define pb push_back
#define f first
#define s second
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define trav(i, x) for(auto& i:x)

const int mx = 550;
vector<int> adj[mx], ans;

void dfs(int i, int p) {
	ans.pb(i);
	trav(u, adj[i]) {
		if (u != p)
			dfs(u, i);
	}
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
	FOR(i, 0, mx)
		adj[i].clear();
	trav(ii, bridges)
		adj[ii.f].pb(ii.s), adj[ii.s].pb(ii.f);

	dfs(1, 0);

	//2^9=512
	// bin search on search vector for ans
	int lo = 0, hi = ans.size()-1;
	while (lo < hi) {
		int mid = (lo+hi)/2;
		vector<int> cur(ans.begin(), ans.begin()+mid);
		if (query(cur))
			hi = mid;
		else
			lo = mid+1;
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 768 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -