114782024-10-06 14:34:53benedekmartonPletykacpp14Runtime error 0/100197ms1692 KiB
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, m, k, egydiak, megegy, p=1; cin >> n >> m >> k;
    set <int> akitudja;
    for (int i = 0; i < k; i++)
    {
        cin >> egydiak;
        akitudja.insert(egydiak);
    }
    vector <int> baratai[5001]; //ide n+1 kell
    for (int i = 0; i < m; i++)
    {
        cin >> egydiak >> megegy;
        baratai[egydiak].push_back(megegy);
        baratai[megegy].push_back(egydiak);
    }
    set <int> ujakitudja;
    vector <int> hanyantudjak;
    hanyantudjak.push_back(akitudja.size());
    while (akitudja.size() < n or akitudja.size() == 0)
    {
        for (auto& i : akitudja)
        {
            for (int j = 0; j < baratai[i].size(); j++)
            {
                ujakitudja.insert(baratai[i][j]);
            }
            //cout << i;
        }
        akitudja.clear();
        for (auto& i : ujakitudja)
        {
            akitudja.insert(i);
            
            //cout << "uj";
        }
        ujakitudja.clear();
        hanyantudjak.push_back(akitudja.size());
        p++;
    }
    cout << n << endl << p << endl;
    for (int i = 0; i < hanyantudjak.size(); i++)
    {
        cout << hanyantudjak[i] << " ";
    }

    
}

SubtaskSumTestVerdictTimeMemory
base0/100
1Accepted0/03ms528 KiB
2Runtime error0/03ms676 KiB
3Time limit exceeded0/2190ms1692 KiB
4Time limit exceeded0/2187ms792 KiB
5Time limit exceeded0/2194ms872 KiB
6Time limit exceeded0/2197ms884 KiB
7Time limit exceeded0/4192ms1052 KiB
8Runtime error0/43ms760 KiB
9Runtime error0/43ms652 KiB
10Runtime error0/43ms656 KiB
11Runtime error0/43ms616 KiB
12Runtime error0/43ms616 KiB
13Runtime error0/43ms760 KiB
14Runtime error0/43ms488 KiB
15Runtime error0/63ms820 KiB
16Runtime error0/63ms548 KiB
17Runtime error0/63ms796 KiB
18Runtime error0/63ms488 KiB
19Runtime error0/63ms748 KiB
20Runtime error0/63ms616 KiB
21Runtime error0/63ms760 KiB
22Runtime error0/63ms616 KiB
23Runtime error0/63ms616 KiB
24Runtime error0/63ms616 KiB