Submission #781623

#TimeUsernameProblemLanguageResultExecution timeMemory
781623AndreyEaster Eggs (info1cup17_eastereggs)C++14
100 / 100
17 ms368 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; vector<int> haha[513]; vector<int> bruh(513); vector<int> wut(0); int br,p; void dfs(int a, int t) { if(p >= br/2) { return; } wut.push_back(a); if(bruh[a] == 1) { bruh[a] = 2; p++; } for(int v: haha[a]) { if(v != t && p < br/2) { dfs(v,a); } } } int findEgg (int n, vector < pair < int, int > > bridges) { for(int i = 0; i < 513; i++) { haha[i].clear(); } int a,b,c; for(int i = 0; i < n-1; i++) { a = bridges[i].first; b = bridges[i].second; haha[a].push_back(b); haha[b].push_back(a); } for(int i = 1; i <= n; i++) { bruh[i] = 1; } br = n; p = 0; while(br > 1) { wut.clear(); p = 0; dfs(1,-1); if(query(wut)) { c = 2; } else { c = 1; } br = 0; for(int i = 1; i <= n; i++) { if(bruh[i] != 0) { if(bruh[i] == c) { br++; bruh[i] = 1; } else { bruh[i] = 0; } } } } for(int i = 1; i <= n; i++) { if(bruh[i] == 1) { return i; } } }

Compilation message (stderr)

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