Submission #518279

#TimeUsernameProblemLanguageResultExecution timeMemory
518279lucriEaster Eggs (info1cup17_eastereggs)C++17
60 / 100
20 ms604 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; /*static int N, X, cntQ; static vector < int > v[1009]; int query (vector < int > h) { cntQ ++; int ap[1009]; if (h.empty ()) return 0; for (int i=1; i<=N; i++) ap[i] = 0; for (auto it = h.begin (); it != h.end (); it ++) ap[*it] = 1; queue < int > cc; cc.push (h[0]), ap[h[0]] = 2; while (!cc.empty ()) { int nod = cc.front (); cc.pop (); for (auto it = v[nod].begin (); it != v[nod].end (); it ++) if (ap[*it] == 1) ap[*it] = 2, cc.push (*it); } for (int i=1; i<=N; i++) if (ap[i] == 1) return -1; for (auto it = h.begin (); it != h.end (); it ++) if (*it == X) return 1; return 0; }*/ vector<int>l[520]; vector<int>q; bool ok[520],part[520]; int nrp; int constructie(int nod,int val) { if(val==nrp) return val; for(auto x:l[nod]) { if(part[x]==false) { part[x]=true; q.push_back(x); if(ok[x]==false) val=constructie(x,val+1); else val=constructie(x,val); if(val==nrp) return val; } } return val; } //int query(vector < int > islands); int findEgg(int N, vector < pair < int, int > > bridges) { for(int i=1;i<=N;++i) { ok[i]=false; while(!l[i].empty()) l[i].pop_back(); } for(auto x:bridges) { l[x.first].push_back(x.second); l[x.second].push_back(x.first); } nrp=N; while(nrp>1) { nrp/=2; q.push_back(1); part[1]=true; if(ok[1]==false) constructie(1,1); else constructie(1,0); if(query(q)) { for(int i=1;i<=N;++i) { if(part[i]==false) ok[i]=true; else part[i]=false; } } else { for(int i=1;i<=N;++i) { if(part[i]==true) { ok[i]=true; part[i]=false; } } } while(!q.empty()) q.pop_back(); } int ans=0; for(int i=1;i<=N;++i) if(ok[i]==false) ans=i; return ans; } /*int main () { freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d", &N); int Queries; vector < pair < int, int > > param; for (int i=1; i<N; i++) { int x, y; scanf ("%d %d", &x, &y); v[x].push_back (y); v[y].push_back (x); param.push_back ({x, y}); } scanf ("%d", &Queries); while (Queries --) { scanf ("%d", &X), cntQ = 0; int Y = findEgg (N, param); if (X != Y) { printf ("WA %d instead of %d\n", Y, X); return 0; } printf ("OK %d\n", cntQ); } return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...