114822024-10-06 15:08:07benedekmartonPletykacpp14Time limit exceeded 4/100199ms9588 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<200) //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
base4/100
1Accepted0/03ms548 KiB
2Time limit exceeded0/0192ms2376 KiB
3Accepted2/23ms488 KiB
4Accepted2/282ms532 KiB
5Time limit exceeded0/2151ms616 KiB
6Time limit exceeded0/2135ms768 KiB
7Time limit exceeded0/4196ms888 KiB
8Wrong answer0/4112ms1128 KiB
9Time limit exceeded0/4196ms1128 KiB
10Time limit exceeded0/4145ms1140 KiB
11Wrong answer0/4100ms2152 KiB
12Time limit exceeded0/4194ms2316 KiB
13Time limit exceeded0/4164ms3216 KiB
14Time limit exceeded0/4199ms3560 KiB
15Time limit exceeded0/6199ms4624 KiB
16Time limit exceeded0/6175ms4328 KiB
17Time limit exceeded0/6195ms5536 KiB
18Time limit exceeded0/6197ms5608 KiB
19Time limit exceeded0/6196ms6120 KiB
20Time limit exceeded0/6194ms6188 KiB
21Time limit exceeded0/6196ms6320 KiB
22Time limit exceeded0/6193ms6288 KiB
23Time limit exceeded0/6197ms9576 KiB
24Time limit exceeded0/6199ms9588 KiB