99232024-03-18 17:04:19111Pletykacpp17Accepted 100/10067ms40368 KiB
#include <bits/stdc++.h>
using namespace std;

auto pi = new char[10000000];
auto po = new char[10000000];
auto po0 = po;

int ru() {
	while (!isdigit(*pi)) {
		pi++;
	}
	int res = 0;
	while (isdigit(*pi)) {
		res *= 10;
		res += *pi - '0';
		pi++;
	}
	return res;
}

void wc(char c) {
	*po++ = c;
}

void wu(int i) {
	int x = 1;
	int c = 1;
	while (x <= i / 10) {
		x *= 10;
		c++;
	}
	while (c--) {
		int d = i / x;
		wc('0' + d);
		i -= d * x;
		i *= 10;
	}
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef CB
	freopen("be2.txt","r",stdin);
//	freopen("out.txt","w",stdout);
#endif
	fread(pi,1,10000000,stdin);
    int N=ru(),M=ru(),K=ru();
    int it=N*2+2;
    vector<int>v(N+1,-1);
    deque<int>q;
    for(int i=0;i<K;i++){
		int a=ru();
		v[a]=0;
		q.push_back(a);
    }
    vector<vector<int>>g(N+1);
    for(int i=0;i<M;i++){
		int a=ru(),b=ru();
		g[a].push_back(b);
		g[b].push_back(a);
    }
    while(!q.empty()){
		int i=q.front();
		q.pop_front();
		for(int j:g[i]){
			if(v[j]==-1){
				v[j]=v[i]+1;
				q.push_back(j);
			}
		}
    }
    vector<vector<int>>d(it);
    vector<int>w(N+1,-1);
    for(int i=1;i<=N;i++){
		if(v[i]==-1){
			continue;
		}
		int x=INT_MAX;
		for(int j:g[i]){
			if(v[j]>=v[i]&&v[j]%2==v[i]%2){
				x=min(x,v[j]);
			}
		}
		if(x!=INT_MAX){
			w[i]=x;
			d[x].push_back(i);
		}
    }
    for(int i=0;i<it;i++){
		for(int j:d[i]){
			if(w[j]<i){
				continue;
			}
			for(int k:g[j]){
				if(w[k]==-1||w[k]>i+1){
					w[k]=i+1;
					d[i+1].push_back(k);
				}
			}
		}
    }
    vector<array<int,2>>b(it);
    vector<int>pf(it);
    int e=0;
    for(int i=1;i<=N;i++){
		if(v[i]==-1){
			continue;
		}
		if (g[i].empty()){
			e++;
			continue;
		}
		b[v[i]][v[i]%2]++;
		if(w[i]==-1){
			continue;
		}
		b[w[i]][v[i]%2]--;
		pf[w[i]]++;
    }
    vector<int>ans(it);
    array<int,2>c{};
    for(int i=0;i<it;i++){
		c[0]+=b[i][0]+pf[i];
		c[1]+=b[i][1]+pf[i];
		ans[i]=c[i%2];
    }
    ans[0]+=e;
    int P=max_element(ans.begin(),ans.end())-ans.begin();
    wu(ans[P]);wc('\n');
    wu(P+1);wc('\n');
    for(int i=0;i<=P;i++){
		wu(ans[i]);wc(' ');
    }
    wc('\n');
    fwrite(po0,1,po-po0,stdout);
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1844 KiB
2Accepted0/017ms12000 KiB
3Accepted2/23ms2400 KiB
4Accepted2/23ms2888 KiB
5Accepted2/23ms3532 KiB
6Accepted2/24ms4400 KiB
7Accepted4/44ms4548 KiB
8Accepted4/46ms6448 KiB
9Accepted4/46ms6204 KiB
10Accepted4/46ms6108 KiB
11Accepted4/417ms13372 KiB
12Accepted4/414ms13160 KiB
13Accepted4/423ms19108 KiB
14Accepted4/427ms20304 KiB
15Accepted6/634ms27248 KiB
16Accepted6/632ms26940 KiB
17Accepted6/646ms33408 KiB
18Accepted6/646ms33944 KiB
19Accepted6/646ms35116 KiB
20Accepted6/645ms35892 KiB
21Accepted6/646ms35864 KiB
22Accepted6/654ms37868 KiB
23Accepted6/664ms40232 KiB
24Accepted6/667ms40368 KiB