Submission #412770

# Submission time Handle Problem Language Result Execution time Memory
412770 2021-05-27T13:26:47 Z aris12345678 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 456 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

const int mxN = 515;
vector<int> adj[mxN];
int euler[mxN];

void dfs(int u, int p, int cnt = 0) {
    euler[cnt++] = u;
    for(auto &v : adj[u]) {
        if(v == p) continue;
        dfs(v, u);
    }
}

int findEgg(int n, vector<pair<int, int> > bridges) {
    for(int i = 1; i <= n; i++)
        adj[i].clear();
    for(int i = 0; i < n-1; i++) {
        adj[bridges[i].first].push_back(bridges[i].second);
        adj[bridges[i].second].push_back(bridges[i].first);
    }
    dfs(1, 0);
    int st = 1, en = n, md, ans;
    while(st <= en) {
        md = (st+en)/2;
        vector<int> check;
        for(int i = st; i <= md; i++)
            check.push_back(euler[i-1]);
        if(query(check)) {
            en = md-1;
            ans = md;
        } else {
            st = md+1;
        }
    }
    return ans;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:38:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |     return ans;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 436 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -