Submission #1096879

# Submission time Handle Problem Language Result Execution time Memory
1096879 2024-10-05T10:33:56 Z 0pt1mus23 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
193 ms 131072 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
const int sze = 1e5;
vector<int> graph[sze];
vector<int> path;

void dfs(int node,int par=-1){
    path.push_back(node);
    for(auto v:graph[node]){
        if(v==par){
            continue;
        }
        dfs(v,node);
    }
}

int findEgg (int n, vector<pair<int,int>> edges){
    int ans=1;
    for(auto [k,v]:edges){
        graph[k].push_back(v);
        graph[v].push_back(k);
    }
    dfs(1);
    int l =0;
    int r = n-1;
    while(l<=r){
        int mid = (l+r)/2;
        vector<int> lst;
        for(int i=0;i<=mid;i++){
            lst.push_back(path[i]);
        }
        if(query(lst)){
            ans=lst.back();
            r = mid-1;
        }
        else{
            l = mid+1;
        }
    }
    return ans;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:21:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   21 |     for(auto [k,v]:edges){
      |              ^
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 150 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 149 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -