Submission #835626

# Submission time Handle Problem Language Result Execution time Memory
835626 2023-08-23T16:44:26 Z VMaksimoski008 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int> > graph;
vector<int> euler;

void dfs(int u, int p) {
    euler.push_back(u);
    for(int &v : graph[u]) {
        if(v == p) continue;
        dfs(v, u);
    }
}

int findEgg(int n, vector<pair<int, int> > edges) {
    graph.clear();
    euler.clear();
    graph.resize(n+1);
    for(auto &x : edges) {
        graph[x.first].push_back(x.second);
        graph[x.second].push_back(x.first);
    }

    dfs(1, 0);
    int l=0, r=euler.size()-1;
    int ans = 0;

    // while(l < r) {
    //     int mid = (l + r) / 2; 
    //     vector<int> to_query(euler.begin(), euler.begin() + mid + 1);

    //     if(query(to_query)) {
    //         ans = mid;
    //         r = mid - 1;
    //     } else l = mid + 1;
    // }

    return euler[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:26:14: warning: unused variable 'r' [-Wunused-variable]
   26 |     int l=0, r=euler.size()-1;
      |              ^
eastereggs.cpp:27:9: warning: unused variable 'ans' [-Wunused-variable]
   27 |     int ans = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB The found island is incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -