Submission #385732

#TimeUsernameProblemLanguageResultExecution timeMemory
385732IwanttobreakfreeEaster Eggs (info1cup17_eastereggs)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; vector<int> c; /*void conexa(vector<vector<int> >& cone,int raiz,int cont,vector<bool>& visto){ c.push_back(raiz); visto[raiz]=true; for(int x: cone[raiz]){ if(c.size()==cont){ return; } if(!visto[x]){ conexa(cone,x,cont,visto); } } }*/ int findEgg (int N, vector < pair < int, int > > bridges){ vector<vector<int> > cone(513,vector<int>()); for(int i=0;i<N-1;i++){ cone[bridges[i].first].push_back(bridges[i].second); cone[bridges[i].second].push_back(bridges[i].first); if(query(bridges[i])){ vector<int> v(1); v[0]=bridges.first; if(query(v))return bridges[i].first; else return bridges[i].second; } } /*int raiz,sol=0; vector<int> lista(N); vector<bool> visto(513,false); conexa(cone,bridges[0].first,N,visto); lista=c; vector<bool> posi(513,true); int cont=N/2; while(cont>0){ c.clear(); for(int i=0;i<N;i++){ if(posi[lista[i]]){ raiz=lista[i]; break; } } vector<bool> visto(513,false); conexa(cone,raiz,cont,visto); if(query(c)){ set<int> s; for(int i=0;i<c.size();i++)s.insert(c[i]); for(int i=0;i<N;i++){ if(s.find(lista[i])==s.end())posi[lista[i]]=false; } sol=c[0]; cone[c[0]].clear(); posi[c[0]]=false; cont/=2; } else { for(int i=0;i<c.size();i++)posi[c[i]]=false; } } return sol;*/ }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:28: error: could not convert 'bridges.std::vector<std::pair<int, int> >::operator[](((std::vector<std::pair<int, int> >::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<int>'
   22 |         if(query(bridges[i])){
      |                            ^
      |                            |
      |                            __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type {aka std::pair<int, int>}
eastereggs.cpp:24:23: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   24 |          v[0]=bridges.first;
      |                       ^~~~~
eastereggs.cpp:18:48: warning: control reaches end of non-void function [-Wreturn-type]
   18 |     vector<vector<int> > cone(513,vector<int>());
      |                                                ^