Submission #895624

#TimeUsernameProblemLanguageResultExecution timeMemory
895624maxFedorchukEaster Eggs (info1cup17_eastereggs)C++14
0 / 100
1 ms792 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; const long long MX=600; vector < int > mas[MX]; int pos1[MX]; int pos2[MX]; /* int query(vector < int > islands) { for(auto u:islands) { cout<<u<<" "; } cout<<"\n"; int ans; cin>>ans; return ans; } */ vector < int > chk(int k1,int n) { for(int i=1;i<=n;i++) { pos2[i]=0; } queue < int > q; q.push(1); int zlk1=k1; while(zlk1!=0) { if(q.empty()) { while(true) { zlk1=1; } } int zar=q.front(); q.pop(); pos2[zar]=1; zlk1-=pos1[zar]; for(auto vr:mas[zar]) { if(!pos2[vr]) { q.push(vr); } } } vector < int > zap; for(int i=1;i<=n;i++) { if(pos2[i]) { zap.push_back(i); } } return zap; } int findEgg(int n, vector < pair < int, int > > bridges) { for(auto [a,b]:bridges) { mas[a].push_back(b); mas[b].push_back(a); } for(int i=1;i<=n;i++) { pos1[i]=1; } int k1=n; while(k1!=1) { int nwk1=k1/2; if(query(chk(nwk1,n))) { for(int i=1;i<=n;i++) { if(pos1[i] && pos2[i]) { pos1[i]=1; } else { pos1[i]=0; } } k1=nwk1; } else { for(int i=1;i<=n;i++) { if(pos1[i] && !pos2[i]) { pos1[i]=1; } else { pos1[i]=0; } } k1-=nwk1; } } for(int i=1;i<=n;i++) { if(pos1[i]==1) { return i; } } } /* int main() { //cin.tie(0); //ios_base::sync_with_stdio(0); int n=5; vector < pair < int , int > > bridges(n-1); bridges[0]=make_pair(1,2); bridges[1]=make_pair(1,3); bridges[2]=make_pair(2,4); bridges[3]=make_pair(4,5); cout<<findEgg(n,bridges)<<"\n"; return 0; } */

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:77:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   77 |     for(auto [a,b]:bridges)
      |              ^
eastereggs.cpp:135:1: warning: control reaches end of non-void function [-Wreturn-type]
  135 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...