114802024-10-06 15:05:59benedekmartonPletykacpp14Time limit exceeded 2/100197ms10912 KiB
#include <iostream>
#include <set>
#include <vector>
#include <fstream>

using namespace std;

int main()
{
    //ifstream cin("be2.txt");
    //ofstream cout("ki.txt");
    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[n+1]; //ide n+1 kell
    for (int i = 0; i < m; i++)
    {
        cin >> egydiak >> megegy;
        baratai[egydiak].push_back(megegy);
        baratai[megegy].push_back(egydiak);
    }
    int pmax = 1, maxi = k;
    set <int> ujakitudja;
    vector <int> hanyantudjak;
    hanyantudjak.push_back(akitudja.size());
    while (p<300) //ez random
    {
        for (auto& i : akitudja)
        {
            for (int j = 0; j < baratai[i].size(); j++)
            {
                ujakitudja.insert(baratai[i][j]);
            }
        }
        akitudja.clear();
        for (auto& i : ujakitudja)
        {
            akitudja.insert(i);
        }
        ujakitudja.clear();
        hanyantudjak.push_back(akitudja.size());
        //cout << akitudja.size() << " ";
        p++;
        if (maxi < akitudja.size())
        {
            maxi = akitudja.size();
            pmax = p;
        }
    }
    cout << maxi << endl << pmax << endl;
    for (int i = 0; i < pmax; i++)
    {
        cout << hanyantudjak[i] << " ";
    }

    
}

SubtaskSumTestVerdictTimeMemory
base2/100
1Accepted0/03ms360 KiB
2Time limit exceeded0/0193ms2664 KiB
3Accepted2/23ms256 KiB
4Time limit exceeded0/2123ms528 KiB
5Time limit exceeded0/2194ms744 KiB
6Time limit exceeded0/2195ms1000 KiB
7Time limit exceeded0/4197ms1000 KiB
8Time limit exceeded0/4196ms1256 KiB
9Time limit exceeded0/4196ms1384 KiB
10Time limit exceeded0/4194ms1316 KiB
11Time limit exceeded0/4197ms2664 KiB
12Time limit exceeded0/4197ms2664 KiB
13Time limit exceeded0/4197ms3816 KiB
14Time limit exceeded0/4194ms4148 KiB
15Time limit exceeded0/6197ms5392 KiB
16Time limit exceeded0/6197ms5188 KiB
17Time limit exceeded0/6196ms6504 KiB
18Time limit exceeded0/6194ms6668 KiB
19Time limit exceeded0/6195ms7312 KiB
20Time limit exceeded0/6193ms7340 KiB
21Time limit exceeded0/6195ms7544 KiB
22Time limit exceeded0/6193ms7564 KiB
23Time limit exceeded0/6194ms10636 KiB
24Time limit exceeded0/6197ms10912 KiB