# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742296 | 2023-05-16T04:39:36 Z | Abrar_Al_Samit | Easter Eggs (info1cup17_eastereggs) | C++17 | 357 ms | 468 KB |
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int nax = 513; bool del[nax]; int sub[nax], par[nax]; vector<int>g[nax]; void dfs(int v, int p = 0) { par[v] = p; sub[v] = 1; for(int u : g[v]) if(u!=p) { if(del[u]) continue; dfs(u, v); sub[v] += sub[u]; } } vector<int>stk; void dfs2(int v, int p) { stk.push_back(v); for(int u : g[v]) if(u!=p) { if(del[u]) continue; dfs2(u, v); } } int findEgg (int N, vector<pair<int,int>>bridges) { memset(del, 0, sizeof del); for(int i=1; i<=N; ++i) { g[i].clear(); } for(int i=0; i<N-1; ++i) { auto [u, v] = bridges[i]; g[u].push_back(v); g[v].push_back(u); } int cur_size = N; while(cur_size>1) { int best = 0, r, v; for(int i=1; i<=N; ++i) if(!del[i]) { dfs(i); for(int j=1; j<=N; ++j) if(!del[j]) { if(sub[j]<=cur_size/2 && best < sub[j]) { best = sub[j]; r = i; v = j; } } } dfs(r); dfs2(v, par[v]); if(query(stk)) { for(int i=1; i<=N; ++i) { del[i] = 1; } cur_size = 0; for(int j : stk) { del[j] = 0; ++cur_size; } } else { for(int j : stk) { del[j] = 1; --cur_size; } } stk.clear(); } for(int i=1; i<=N; ++i) if(!del[i]) { return i; } assert(0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Number of queries: 4 |
2 | Partially correct | 1 ms | 208 KB | Number of queries: 5 |
3 | Partially correct | 1 ms | 208 KB | Number of queries: 9 |
4 | Partially correct | 2 ms | 208 KB | Number of queries: 15 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 336 KB | Number of queries: 8 |
2 | Partially correct | 105 ms | 336 KB | Number of queries: 12 |
3 | Partially correct | 344 ms | 336 KB | Number of queries: 28 |
4 | Runtime error | 31 ms | 468 KB | Execution killed with signal 6 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 331 ms | 336 KB | Number of queries: 9 |
2 | Partially correct | 208 ms | 336 KB | Number of queries: 12 |
3 | Partially correct | 357 ms | 336 KB | Number of queries: 28 |
4 | Runtime error | 7 ms | 464 KB | Execution killed with signal 6 |
5 | Halted | 0 ms | 0 KB | - |