Submission #61653

# Submission time Handle Problem Language Result Execution time Memory
61653 2018-07-26T09:04:07 Z EntityIT Easter Eggs (info1cup17_eastereggs) C++14
40 / 100
5 ms 784 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 600;
int a[N], cur;
vector<int> gr[N];

void dfs(int u, int p) {
    a[++cur] = u;
    for (int v : gr[u]) if(v != p) dfs(v, u);
}

int findEgg(int n, vector<ii> edge) {
    for (int i = 0; i < N; ++i) gr[i].clear();
    for (ii i : edge) {
        gr[i.fi].pb(i.se); gr[i.se].pb(i.fi);
    }
    dfs(1, 1);

    vector<int> ask;
    int l = 1, r = n;

    while(l < r) {
        int mid = l + r >> 1;
        ask.clear();
        for (int i = 1; i <= mid; ++i) ask.pb(a[i]);
        if(query(ask)) r = mid;
        else l = mid + 1;
    }
    return a[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:31:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = l + r >> 1;
                   ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 248 KB Number of queries: 4
2 Correct 3 ms 436 KB Number of queries: 4
3 Correct 4 ms 496 KB Number of queries: 4
4 Correct 4 ms 528 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -