#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, m, k;
cin >> n >> m >> k;
vector<int> kezd(k);
vector<bool> parosban(n+1, false);
vector<bool> paratlanban(n+1, false);
for(int &x : kezd){
cin >> x;
parosban[x] = true;
}
vector<vector<int>> graf(n+1, vector<int>());
int a, b;
for(int i = 0; i < m; i++){
cin >> a >> b;
graf[a].push_back(b);
graf[b].push_back(a);
}
queue<int> ujak;
for(int x : kezd){
ujak.push(x);
}
int ido = 0;
int ptl_db = 0, ps_db = k;
int akt;
int reteg_meret = k, kov_reteg_meret = 0;
vector<int> mo;
while(!ujak.empty()){
akt = ujak.front();
//cout << "akt: " << akt << " ido: " << ido << " ptl_db: " << ptl_db << " ps_db: " << ps_db << "\n";
ujak.pop();
reteg_meret--;
if(ido % 2){
for(int kov : graf[akt]){
if(parosban[kov]) continue;
parosban[kov] = true;
ps_db++;
ujak.push(kov);
kov_reteg_meret++;
}
}
else{
for(int kov : graf[akt]){
if(paratlanban[kov]) continue;
paratlanban[kov] = true;
ptl_db++;
ujak.push(kov);
kov_reteg_meret++;
}
}
if(reteg_meret == 0){
mo.push_back((ido % 2 ? ptl_db : ps_db));
ido++;
swap(reteg_meret, kov_reteg_meret);
}
}
int db = max(ptl_db, ps_db);
cout << db << "\n";
vector<int> temp;
for(int x : mo){
temp.push_back(x);
if(x == db) break;
}
cout << temp.size() << "\n";
for(int x : temp){
cout << x << " ";
}
cout << "\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
base | 63/100 | ||||||
1 | Accepted | 0/0 | 3ms | 2012 KiB | |||
2 | Wrong answer | 0/0 | 17ms | 6296 KiB | |||
3 | Accepted | 2/2 | 3ms | 2964 KiB | |||
4 | Partially correct | 1/2 | 3ms | 3124 KiB | |||
5 | Wrong answer | 0/2 | 3ms | 3288 KiB | |||
6 | Wrong answer | 0/2 | 4ms | 3880 KiB | |||
7 | Accepted | 4/4 | 4ms | 4056 KiB | |||
8 | Wrong answer | 0/4 | 7ms | 4920 KiB | |||
9 | Accepted | 4/4 | 7ms | 5100 KiB | |||
10 | Accepted | 4/4 | 6ms | 5172 KiB | |||
11 | Wrong answer | 0/4 | 17ms | 8396 KiB | |||
12 | Accepted | 4/4 | 16ms | 8728 KiB | |||
13 | Partially correct | 2/4 | 25ms | 11704 KiB | |||
14 | Wrong answer | 0/4 | 27ms | 12544 KiB | |||
15 | Wrong answer | 0/6 | 37ms | 16040 KiB | |||
16 | Accepted | 6/6 | 37ms | 16748 KiB | |||
17 | Wrong answer | 0/6 | 46ms | 20288 KiB | |||
18 | Accepted | 6/6 | 50ms | 21340 KiB | |||
19 | Accepted | 6/6 | 48ms | 23008 KiB | |||
20 | Wrong answer | 0/6 | 48ms | 24312 KiB | |||
21 | Accepted | 6/6 | 50ms | 25472 KiB | |||
22 | Accepted | 6/6 | 54ms | 27348 KiB | |||
23 | Accepted | 6/6 | 89ms | 30912 KiB | |||
24 | Accepted | 6/6 | 89ms | 33428 KiB |