Submission #1066196

# Submission time Handle Problem Language Result Execution time Memory
1066196 2024-08-19T16:15:56 Z Malix Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
18 ms 600 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))

int findEgg (int N, vector < pair < int, int > > bridges)
{
    int n=N;
    vii a(n);
    REP(i,0,n-1){
        a[bridges[i].F-1].PB(bridges[i].S-1);
        a[bridges[i].S-1].PB(bridges[i].F-1);
    }
    vi vis(n,0);
    vi arr;
    queue<int> pq;
    pq.push(0);
    while(!pq.empty()){
        int x=pq.front();
        pq.pop();
        if(vis[x])continue;
        vis[x]=1;
        arr.PB(x);
        for(auto u:a[x])pq.push(u);
    }
    int l=0,r=n-1;
    while(l<r){
        int m=(l+r)/2;
        vi b;
        REP(i,0,m+1)b.PB(arr[i]+1);
        if(!query(b))l=m+1;
        else r=m;
    }
    return arr[l]+1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 480 KB Number of queries: 8
2 Correct 7 ms 344 KB Number of queries: 9
3 Correct 11 ms 488 KB Number of queries: 9
4 Correct 12 ms 600 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 11 ms 344 KB Number of queries: 9
2 Correct 10 ms 344 KB Number of queries: 9
3 Correct 11 ms 508 KB Number of queries: 9
4 Correct 18 ms 344 KB Number of queries: 9