53562023-04-26 12:07:55sztomiPletykacpp11Wrong answer 63/10089ms33428 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;
        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";
}
SubtaskSumTestVerdictTimeMemory
base63/100
1Accepted0/03ms2012 KiB
2Wrong answer0/017ms6296 KiB
3Accepted2/23ms2964 KiB
4Partially correct1/23ms3124 KiB
5Wrong answer0/23ms3288 KiB
6Wrong answer0/24ms3880 KiB
7Accepted4/44ms4056 KiB
8Wrong answer0/47ms4920 KiB
9Accepted4/47ms5100 KiB
10Accepted4/46ms5172 KiB
11Wrong answer0/417ms8396 KiB
12Accepted4/416ms8728 KiB
13Partially correct2/425ms11704 KiB
14Wrong answer0/427ms12544 KiB
15Wrong answer0/637ms16040 KiB
16Accepted6/637ms16748 KiB
17Wrong answer0/646ms20288 KiB
18Accepted6/650ms21340 KiB
19Accepted6/648ms23008 KiB
20Wrong answer0/648ms24312 KiB
21Accepted6/650ms25472 KiB
22Accepted6/654ms27348 KiB
23Accepted6/689ms30912 KiB
24Accepted6/689ms33428 KiB