# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
389338 | 2021-04-14T03:12:34 Z | casperwang | Easter Eggs (info1cup17_eastereggs) | C++14 | 39 ms | 456 KB |
#include <bits/stdc++.h> #include "grader.h" #define pii pair<int,int> #define ff first #define ss second #define All(x) x.begin(), x.end() #define pb push_back using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; } const int MAXN = 512; int N; vector <int> path[MAXN+1]; vector <int> qry; set <int> can; int qry_sze; void init(int n, vector <pii> bridges) { N = n; can.clear(); for (int i = 1; i <= N; i++) { path[i].clear(); can.insert(i); } for (auto [a, b] : bridges) { path[a].pb(b); path[b].pb(a); } } void dfs_get(int now, int par) { if (qry_sze * 2 >= can.size()) return; qry.pb(now); if (can.find(now) != can.end()) qry_sze++; for (int i : path[now]) { if (i == par) continue; dfs_get(i, now); } } int solve() { if (can.size() == 1) return *can.begin(); qry_sze = 0; dfs_get(*can.begin(), 0); bool flag = query(qry); qry.pb(N+1); if (flag) { set <int> tmp; for (int i : qry) if (can.find(i) != can.end()) tmp.insert(i); can = tmp; } else { for (int i : qry) can.erase(i); } qry.clear(); return solve(); } int findEgg (int n, vector <pii> bridges) { init(n, bridges); return solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 200 KB | Number of queries: 4 |
2 | Correct | 1 ms | 200 KB | Number of queries: 4 |
3 | Correct | 2 ms | 200 KB | Number of queries: 4 |
4 | Correct | 1 ms | 200 KB | Number of queries: 4 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 352 KB | Number of queries: 8 |
2 | Correct | 13 ms | 360 KB | Number of queries: 9 |
3 | Correct | 24 ms | 456 KB | Number of queries: 9 |
4 | Correct | 26 ms | 368 KB | Number of queries: 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 456 KB | Number of queries: 9 |
2 | Correct | 28 ms | 356 KB | Number of queries: 9 |
3 | Correct | 30 ms | 456 KB | Number of queries: 9 |
4 | Correct | 39 ms | 332 KB | Number of queries: 9 |