2682021-05-17 11:26:08kidesoElfogáscpp11Wrong answer 0/5052ms9044 KiB
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct adat
{
	bool lat;
	vector <int> sz;
};

vector <adat> x;
queue <int> y;
int N, M, U, V;

int main()
{
	cin >> N >> M >> U >> V;
	x.resize(N + 1);

	int a, b;
	for (int i = 1; i <= M; ++i)
	{
		cin >> a >> b;
		x[a].sz.push_back(b);
		x[b].sz.push_back(a);
	}

	y.push(V);
	int db = 0;
	x[V].lat = true;
	while (!y.empty())
	{
		++db;
		int akt = y.front();
		y.pop();

		if (akt != U)
		{
			for(auto e:x[akt].sz)
				if (!x[e].lat)
				{
					x[e].lat = true;
					y.push(e);
				}
		}
	}

	x[U].lat = false;
	cout << db - 1 << '\n';
	for (int i = 1; i <= N; ++i)
		if (x[i].lat) cout << i << ' ';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/02ms1740 KiB
2Wrong answer0/08ms2636 KiB
3Wrong answer0/21ms1944 KiB
4Wrong answer0/23ms1968 KiB
5Wrong answer0/22ms1988 KiB
6Wrong answer0/22ms2008 KiB
7Wrong answer0/32ms2024 KiB
8Wrong answer0/32ms2040 KiB
9Wrong answer0/34ms2252 KiB
10Wrong answer0/34ms2296 KiB
11Wrong answer0/37ms2596 KiB
12Wrong answer0/38ms2864 KiB
13Wrong answer0/38ms2972 KiB
14Wrong answer0/38ms3200 KiB
15Wrong answer0/38ms3300 KiB
16Wrong answer0/335ms5100 KiB
17Wrong answer0/335ms5912 KiB
18Wrong answer0/335ms6612 KiB
19Wrong answer0/335ms7180 KiB
20Wrong answer0/352ms9044 KiB