13032022-04-09 22:07:30ZsofiaKeresztelyPletykacpp14Accepted 100/100108ms34364 KiB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, k, c=0;
	cin>>n>>m>>k;
	vector<vector<int> > g(n+1);
	vector<vector<bool> > volt(2, vector<bool>(n+1, false));
	vector<vector<int> > tav(2, vector<int>(n+1, 0));
	vector<int> napok(2*n, 0);
	vector<int> merges(k);
	queue<pair<int, int> > q; //sorszama, paritas
	for (int i=0; i<k; i++)
	{
		cin>>merges[i];
		q.push(mp(merges[i], 0));
		volt[0][merges[i]]=true;
	}
	int a, b;
	for (int i=0; i<m; i++)
	{
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int x : merges)
	{
		if (!g[x].size())
		{
			c++;
		}
	}
	pair<int, int> elso;
	while (!q.empty())
	{
		elso=q.front();
		q.pop();
		for (int x : g[elso.first])
		{
			if (!volt[1-elso.second][x])
			{
				volt[1-elso.second][x]=true;
				q.push(mp(x, 1-elso.second));
				tav[1-elso.second][x]=tav[elso.second][elso.first]+1;
				napok[tav[1-elso.second][x]]++;
			}
		}
	}
	napok[0]=k-c;
	int maxi=0;
	if (napok[1]>napok[maxi])
	{
		maxi=1;
	}
	for (int i=2; i<2*n; i++)
	{
		napok[i]+=napok[i-2];
		if (napok[i]>napok[maxi])
		{
			maxi=i;
		}
	}
	if (k>napok[maxi])
	{
		maxi=0;
	}
	napok[0]=k;
	cout<<napok[maxi]<<"\n"<<maxi+1<<"\n";
	for (int i=0; i<=maxi; i++)
	{
		cout<<napok[i]<<" ";
	}
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/02ms1812 KiB
2Accepted0/017ms6224 KiB
3Accepted2/21ms2204 KiB
4Accepted2/22ms2280 KiB
5Accepted2/22ms2492 KiB
6Accepted2/24ms2976 KiB
7Accepted4/44ms3020 KiB
8Accepted4/46ms3688 KiB
9Accepted4/44ms3788 KiB
10Accepted4/44ms3884 KiB
11Accepted4/417ms6964 KiB
12Accepted4/416ms7300 KiB
13Accepted4/428ms10852 KiB
14Accepted4/432ms11440 KiB
15Accepted6/646ms15092 KiB
16Accepted6/643ms15908 KiB
17Accepted6/671ms19756 KiB
18Accepted6/663ms20804 KiB
19Accepted6/657ms23240 KiB
20Accepted6/674ms24416 KiB
21Accepted6/675ms25556 KiB
22Accepted6/674ms26724 KiB
23Accepted6/6108ms32052 KiB
24Accepted6/6103ms34364 KiB