# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
319077 | 2020-11-03T20:57:01 Z | NachoLibre | Easter Eggs (info1cup17_eastereggs) | C++14 | 22 ms | 448 KB |
#include <bits/stdc++.h> using namespace std; int query(vector<int> islads); vector<int> v[513], ve; int bo[513], c, a; void sgd(int dg, int op) { ve.push_back(dg); if(bo[dg]) ++a; if(a == c / 2) return; for(int i = 0; i < v[dg].size(); ++i) { if(v[dg][i] != op) { sgd(v[dg][i], dg); if(a == c / 2) return; } } } int findEgg(int n, vector<pair<int, int> > brd) { for(int i = 1; i <= n; ++i) { v[i].clear(); bo[i] = 1; } for(int i = 0; i < n - 1; ++i) { v[brd[i].first].push_back(brd[i].second); v[brd[i].second].push_back(brd[i].first); } c = n; while(c > 1) { ve.clear(); a = 0; sgd(1, 0); if(query(ve)) { for(int i = 0; i < ve.size(); ++i) { if(bo[ve[i]]) bo[ve[i]] = 2; } for(int i = 1; i <= n; ++i) { if(bo[i] == 1) bo[i] = 0, --c; } for(int i = 1; i <= n; ++i) { if(bo[i] == 2) bo[i] = 1; } } else { for(int i = 0; i < ve.size(); ++i) { if(bo[ve[i]]) bo[ve[i]] = 0, --c; } } } for(int i = 1; i <= n; ++i) { if(bo[i]) return i; } } /* int main() { ios::sync_with_stdio(0); cin.tie(0); return 0; } */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Number of queries: 4 |
2 | Correct | 1 ms | 364 KB | Number of queries: 4 |
3 | Correct | 1 ms | 364 KB | Number of queries: 4 |
4 | Correct | 1 ms | 364 KB | Number of queries: 4 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 364 KB | Number of queries: 8 |
2 | Correct | 14 ms | 448 KB | Number of queries: 9 |
3 | Correct | 22 ms | 432 KB | Number of queries: 9 |
4 | Correct | 20 ms | 364 KB | Number of queries: 9 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 364 KB | Number of queries: 9 |
2 | Correct | 19 ms | 364 KB | Number of queries: 9 |
3 | Correct | 21 ms | 384 KB | Number of queries: 9 |
4 | Correct | 19 ms | 432 KB | Number of queries: 9 |