Submission #61981

# Submission time Handle Problem Language Result Execution time Memory
61981 2018-07-27T07:19:17 Z minhcool Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
76 ms 3108 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 = 1e5 + 5;
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 13 ms 2648 KB Number of queries: 4
2 Correct 8 ms 2832 KB Number of queries: 4
3 Correct 10 ms 2920 KB Number of queries: 4
4 Correct 11 ms 2920 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2920 KB Number of queries: 8
2 Correct 45 ms 2972 KB Number of queries: 9
3 Correct 67 ms 3076 KB Number of queries: 9
4 Correct 58 ms 3076 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3088 KB Number of queries: 9
2 Correct 76 ms 3108 KB Number of queries: 9
3 Correct 55 ms 3108 KB Number of queries: 9
4 Correct 52 ms 3108 KB Number of queries: 9