Submission #61617

# Submission time Handle Problem Language Result Execution time Memory
61617 2018-07-26T08:12:21 Z Flying_dragon_02 Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 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++){
                    ~~^~~~~~~~~~~~~~~~
eastereggs.cpp:35:20: error: 'n' was not declared in this scope
     int l = 1, r = n, mid;
                    ^
eastereggs.cpp:37:6: error: 'mid' was not declared in this scope
      mid = (l + r) / 2;
      ^~~