53572023-04-26 12:29:57sztomiPletykacpp11Accepted 100/10090ms17620 KiB
#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;
    }
    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){
        if(graf[x].size() > 0){
            ujak.push(x);
            parosban[x] = true;
        }
    }


    int ido = 0;
    int ptl_db = 0, ps_db = ujak.size();
    int akt;
    int reteg_meret = ujak.size(), 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);

    if(k < db){
        cout << db << "\n";
        vector<int> temp;
        for(int x : mo){
            temp.push_back(x);
            if(x == db) break;
        }
        cout << temp.size() << "\n";
        cout << k << " ";
        for(int i = 1; i < temp.size(); i++){
            cout << temp[i] << " ";
        }
        cout << "\n";
    }
    else{
        cout << k << "\n";
        cout << "1\n";
        cout << k << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/03ms1828 KiB
2Accepted0/017ms5700 KiB
3Accepted2/23ms2236 KiB
4Accepted2/23ms2500 KiB
5Accepted2/23ms2792 KiB
6Accepted2/24ms3168 KiB
7Accepted4/44ms3496 KiB
8Accepted4/47ms4168 KiB
9Accepted4/46ms4324 KiB
10Accepted4/47ms4464 KiB
11Accepted4/417ms7032 KiB
12Accepted4/416ms6888 KiB
13Accepted4/425ms9116 KiB
14Accepted4/427ms9664 KiB
15Accepted6/637ms12420 KiB
16Accepted6/637ms12432 KiB
17Accepted6/646ms14784 KiB
18Accepted6/646ms15044 KiB
19Accepted6/646ms15620 KiB
20Accepted6/650ms15628 KiB
21Accepted6/650ms15624 KiB
22Accepted6/654ms16140 KiB
23Accepted6/690ms17620 KiB
24Accepted6/690ms17356 KiB