99182024-03-18 16:53:03111Pletykacpp17Wrong answer 51/100128ms55324 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef CB
	freopen("be2.txt","r",stdin);
//	freopen("out.txt","w",stdout);
#endif
    int N,M,K;
    cin>>N>>M>>K;
    int it=N*2+2;
    vector<int>v(N+1,-1);
    deque<int>q;
    for(int i=0;i<K;i++){
		int a;
		cin>>a;
		v[a]=0;
		q.push_back(a);
    }
    vector<vector<int>>g(N+1);
    for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		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);
    for(int i=1;i<=N;i++){
		if(v[i]==-1){
			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];
    }
    int P=max_element(ans.begin(),ans.end())-ans.begin();
    cout<<ans[P]<<'\n';
    cout<<P+1<<'\n';
    for(int i=0;i<=P;i++){
		cout<<ans[i]<<' ';
    }
    cout<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base51/100
1Accepted0/03ms2104 KiB
2Wrong answer0/023ms13872 KiB
3Accepted2/23ms2584 KiB
4Partially correct1/23ms3112 KiB
5Wrong answer0/24ms3856 KiB
6Wrong answer0/26ms5228 KiB
7Accepted4/46ms5240 KiB
8Wrong answer0/48ms7216 KiB
9Accepted4/48ms7160 KiB
10Accepted4/48ms7248 KiB
11Wrong answer0/423ms15580 KiB
12Accepted4/421ms15668 KiB
13Partially correct2/435ms23104 KiB
14Wrong answer0/439ms24944 KiB
15Wrong answer0/654ms33740 KiB
16Accepted6/654ms34324 KiB
17Wrong answer0/671ms43008 KiB
18Accepted6/672ms45260 KiB
19Accepted6/671ms48044 KiB
20Wrong answer0/675ms49256 KiB
21Accepted6/674ms49376 KiB
22Accepted6/682ms50736 KiB
23Time limit exceeded0/6128ms55324 KiB
24Time limit exceeded0/6128ms55104 KiB