5771 | 2023-09-25 09:50:08 | zsebi | Elágazás nélküli úton levő települések (50 pont) | cpp11 | Compilation error |
// elagazas nelkul.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <queue>
#define ll long long
using namespace std;
struct adat
{
vector<ll>sz;
};
ll n, m;
int main()
{
cin >> n >> m;
vector<adat>x(n+1);
vector<ll>ans;
for (int i = 1; i <= m; ++i)
{
ll a, b;
cin >> a >> b;
x[a].sz.push_back(b);
x[b].sz.push_back(a);
}
vector<ll>volt;
for (int i=1;i<=n;++i)
{
if (x[i].sz.size() == 1)
{
deque<ll>v;
v.push_back(i);
while (!v.empty())
{
ll akt = v.front();
volt.push_back(akt);
v.pop_front();
for (auto& e : x[akt].sz)
{
auto res = find(volt.begin(), volt.end(), e);
if (res == end(volt))
{
ans.push_back(e);
if (x[e].sz.size() <= 2)v.push_back(e);
}
}
}
volt.clear();
}
}
cout << ans.size() << "\n";
for (auto& e : ans)cout << e<<" ";
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
exit status 1
main.cpp: In function 'int main()':
main.cpp:43:36: error: no matching function for call to 'find(std::vector<long long int>::iterator, std::vector<long long int>::iterator, long long int&)'
43 | auto res = find(volt.begin(), volt.end(), e);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/locale_facets.h:48,
from /usr/include/c++/11/bits/basic_ios.h:37,
from /usr/include/c++/11/ios:44,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from main.cpp:4:
/usr/include/c++/11/bits/streambuf_iterator.h:421:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >,...