4104 | 2023-03-14 15:28:10 | Tibi23 | Elágazás nélküli úton levő települések (50 pont) | cpp11 | Compilation error |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool bennnVan(vector<int> x, int szam){
for (int i=0; i<x.size();i++){
if(x[i]==szam){
return true;
}
}
return false;
}
int main()
{
int n;
cin>>n;
int m;
cin>>m;
vector<int> utak[n+1];
int honnan, hova;
for(int i=0; i<m; i++){
cin>>honnan;
cin>>hova;
utak[honnan].push_back(hova);
utak[hova].push_back(honnan);
}
vector<int> zsakfaluk;
for(int i=1; i<=n; i++){
if(utak[i].size()==1)
zsakfaluk.push_back(i);
}
/*for(int x : zsakfaluk){
cout<<x<<endl;
}*/
vector<int> megoldas;
int aktualis,elozo;
for(int x : zsakfaluk){
aktualis = utak[x][0];
elozo=x;
if(! benneVan(megoldas,aktualis))
megoldas.push_back(aktualis);
while(utak[aktualis].size()==2){
if(utak[aktualis][0]!=elozo){
elozo=aktualis;
aktualis=utak[aktualis][0];
}
else{
elozo=aktualis;
aktualis=utak[aktualis][1];
}
if(! benneVan(megoldas,aktualis))
megoldas.push_back(aktualis);
}
}
sort(megoldas.begin(),megoldas.end());
cout<<megoldas.size()<<endl;
for(int x : megoldas)
cout<<x<<" ";
return 0;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:53:13: error: 'benneVan' was not declared in this scope; did you mean 'bennnVan'?
53 | if(! benneVan(megoldas,aktualis))
| ^~~~~~~~
| bennnVan
main.cpp:66:14: error: 'benneVan' was not declared in this scope; did you mean 'bennnVan'?
66 | if(! benneVan(megoldas,aktualis))
| ^~~~~~~~
| bennnVan
Exited with error status 1