Submission #762154

#TimeUsernameProblemLanguageResultExecution timeMemory
762154maomao90Easter Eggs (info1cup17_eastereggs)C++17
100 / 100
19 ms476 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; #define REP(i, j, k) for (int i = (j); i < (k); i++) #define RREP(i, j, k) for (int i = (j); i >= (k); i--) template <class T> inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;} template <class T> inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;} typedef long long ll; typedef long double ld; #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define ALL(x) x.begin(), x.end() #define SZ(x) (int) x.size() #define pb push_back typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; typedef tuple<int, int, int> iii; typedef vector<iii> viii; #ifndef DEBUG #define cerr if (0) cerr #endif const int INF = 1000000005; const ll LINF = 1000000000000000005; const int MAXN = 600; int n; vi adj[MAXN]; bool guilty[MAXN], vis[MAXN]; int findEgg (int N, vii bridges) { n = N; REP (i, 1, n + 1) { adj[i].clear(); } REP (i, 0, n - 1) { auto [u, v] = bridges[i]; adj[u].pb(v); adj[v].pb(u); } REP (i, 1, n + 1) { guilty[i] = 1; } while (1) { queue<int> bfs; bfs.push(1); int all = 0; REP (i, 1, n + 1) { all += guilty[i]; vis[i] = 0; } if (all == 1) { break; } int cnt = 0; while (!bfs.empty()) { int u = bfs.front(); bfs.pop(); vis[u] = 1; cnt += guilty[u]; if (cnt >= all / 2) { break; } for (int v : adj[u]) { if (vis[v]) { continue; } bfs.push(v); } } vi qry; cerr << "QUERY: "; REP (i, 1, n + 1) { if (vis[i]) { qry.pb(i); cerr << i << ' '; } } cerr << '\n'; bool res = query(qry); cerr << "RETURN: " << res << '\n'; REP (i, 1, n + 1) { if (guilty[i]) { guilty[i] ^= res ^ vis[i]; } } } REP (i, 1, n + 1) { if (guilty[i]) { return i; } } }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, vii)':
eastereggs.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
  101 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...