Submission #918025

# Submission time Handle Problem Language Result Execution time Memory
918025 2024-01-29T12:28:57 Z Elwino008 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 508 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

#define endl '\n'
#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
//#define int ll
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
#define all(v) v.begin(), v.end()
#define pss pair<string, string>
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define imp cout<<-1<<endl;
#define flu cout.flush();

int n, used[555];
vector<int>a[555];
vector<int>nodes;

void dfs(int node){
    used[node]=1;
    nodes.pb(node);
    for(int i : a[node]){
        if(used[i]==0){
            dfs(i);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(pii i : bridges){
        int f=i.F, s=i.S;
        a[f].pb(s);
        a[s].pb(f);
    }
    dfs(1);
    n=N;
    int l=0, r=n-2;
    while(l<=r){
        int mid=(l+r)/2;
        vector<int>v;
        for(int i=l; i<=mid; i++){
            v.pb(nodes[i]);
        }
        int ans;
        ans=query(v);
        if(ans==1){
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    return r+1;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 472 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 508 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -