답안 #144108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144108 2019-08-16T04:39:45 Z Flying_dragon_02 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
20 ms 412 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
typedef pair<int, int> ii;
 
vector<int> graph[600];
int child[600], m, root, par[600], ok = 0, arr[600], num = 1;
bool vis1[600], vis2[600];
vector<int> ask;
 
void dfs(int u, int p){
	arr[num] = u; num++;
    for(int i = 0; i < graph[u].size(); i++){
        int v = graph[u][i];
        if(v == p) continue;
        dfs(v, u);
    }
}
 
int findEgg(int N, vector<ii> bridges){
	for(int i = 1; i <= N; i++)
		graph[i].clear();
	num = 1;
    for(int i = 0; i < bridges.size(); i++){
        int u = bridges[i].fi, v = bridges[i].se;
        graph[u].pb(v); graph[v].pb(u);
    }
    dfs(1, 1);
    int l = 1, r = N, mid;
    while(l < r){
    	mid = (l + r) / 2;
    	ask.clear();
    	for(int j = 1; j <= mid; j++)
    		ask.pb(arr[j]);
    	if(query(ask)) r = mid;
    	else
    	l = mid + 1;
	}
	return arr[l];
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:19:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < graph[u].size(); i++){
                    ~~^~~~~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:30:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < bridges.size(); i++){
                    ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 412 KB Number of queries: 4
2 Correct 3 ms 376 KB Number of queries: 4
3 Correct 2 ms 376 KB Number of queries: 4
4 Correct 2 ms 248 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 248 KB Number of queries: 8
2 Correct 14 ms 248 KB Number of queries: 9
3 Correct 16 ms 376 KB Number of queries: 9
4 Correct 18 ms 248 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Number of queries: 9
2 Correct 18 ms 248 KB Number of queries: 9
3 Correct 16 ms 376 KB Number of queries: 9
4 Correct 18 ms 376 KB Number of queries: 9