Submission #464805

# Submission time Handle Problem Language Result Execution time Memory
464805 2021-08-14T07:58:32 Z okaragul Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int>> g;
vector<int> ord;

int dfs(int v, int p){
    ord.push_back(v);
    for(auto &ch:g[v]) if(ch!=p) dfs(ch, v);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    g.assign(N, vector<int>()); ord.clear();
    for(int i = 1; i < N; i++){
        int &[a, b]=bridges[i-1];
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    dfs(0, -1);
    int l=1, r=n;
    while(l<r){
        int mid=(l+r)/2;
        
        vector<int> tmp;
        for(int i = 0; i < mid; i++) tmp.push_back(ord[i]);

        if(!query(tmp)) l=mid+1;
        else r=mid;
    }
    return l;
}

Compilation message

eastereggs.cpp: In function 'int dfs(int, int)':
eastereggs.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | }
      | ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:17:14: error: structured binding declaration cannot have type 'int'
   17 |         int &[a, b]=bridges[i-1];
      |              ^~~~~~
eastereggs.cpp:17:14: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
eastereggs.cpp:22:16: error: 'n' was not declared in this scope
   22 |     int l=1, r=n;
      |                ^