# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893992 | 2023-12-27T18:25:13 Z | raphaelp | Easter Eggs (info1cup17_eastereggs) | C++14 | 1 ms | 632 KB |
#include <bits/stdc++.h> #include "grader.h" using namespace std; void dfs(int x, int p, int &targ, vector<int> &taken, vector<int> &occ, vector<vector<int>> &Tab) { targ -= occ[x]; taken.push_back(x + 1); if (targ == 0) return; for (int i = 0; i < Tab[x].size(); i++) { if (Tab[x][i] == p) continue; dfs(Tab[x][i], x, targ, taken, occ, Tab); } } int findEgg(int N, vector<pair<int, int>> bridges) { vector<int> occ(N, 1); vector<vector<int>> Tab(N); for (int i = 0; i < N - 1; i++) { Tab[bridges[i].first - 1].push_back(bridges[i].second - 1); Tab[bridges[i].second - 1].push_back(bridges[i].first - 1); } int num = N; while (num > 1) { vector<int> taken; int targ = num / 2; dfs(0, 0, targ, taken, occ, Tab); int temp = query(taken); if (temp) { num = targ; sort(taken.begin(), taken.end()); int buff = 0; for (int i = 0; i < N; i++) { if (i == taken[buff] - 1) { buff++; continue; } occ[i] = 0; } } else { num -= targ; for (int i = 0; i < taken.size(); i++) { occ[i] = 0; } } } int ans; for (int i = 0; i < N; i++) { if (occ[i]) ans = i + 1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 432 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 632 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 524 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |