13012022-04-09 21:42:27ZsofiaKeresztelyPletykacpp14Wrong answer 45/100197ms26664 KiB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair

int main() {
	int n, m, k, a, b;
	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);
	napok[0]=k;
	queue<pair<int, int> > q; //sorszama, paritas
	for (int i=0; i<k; i++)
	{
		cin>>a;
		q.push(mp(a, 0));
		volt[0][a]=true;
	}
	for (int i=0; i<m; i++)
	{
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	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]]++;
			}
		}
	}
	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;
		}
	}
	cout<<napok[maxi]<<"\n"<<maxi+1<<"\n";
	for (int i=0; i<=maxi; i++)
	{
		cout<<napok[i]<<" ";
	}
}
SubtaskSumTestVerdictTimeMemory
base45/100
1Accepted0/02ms1776 KiB
2Wrong answer0/030ms6144 KiB
3Accepted2/21ms2188 KiB
4Partially correct1/22ms2260 KiB
5Wrong answer0/23ms2472 KiB
6Wrong answer0/24ms2956 KiB
7Accepted4/48ms3004 KiB
8Wrong answer0/416ms3688 KiB
9Accepted4/48ms3788 KiB
10Accepted4/48ms3884 KiB
11Wrong answer0/430ms6968 KiB
12Accepted4/428ms7300 KiB
13Partially correct2/450ms10708 KiB
14Wrong answer0/448ms11284 KiB
15Wrong answer0/681ms14928 KiB
16Accepted6/671ms15800 KiB
17Wrong answer0/697ms19616 KiB
18Accepted6/6100ms20648 KiB
19Accepted6/6108ms23148 KiB
20Wrong answer0/6115ms24352 KiB
21Accepted6/6115ms25464 KiB
22Time limit exceeded0/6122ms26664 KiB
23Time limit exceeded0/6197ms22200 KiB
24Time limit exceeded0/6123ms23100 KiB