97272024-03-04 11:42:52tamasmarkFertőzési sorozat (50 pont)cpp17Wrong answer 0/5052ms6052 KiB
// fertozesisorozat.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <algorithm>

using namespace std;

struct adat
{
    int lep,minlep;
    int lat;
    bool kezd;
    vector<int>sz;
};
vector<adat>x;
int n, m, i, j, a, b,akt;
deque<int>v, lista,megold;
int main()
{
    cin >> n >> m >> a;
    lista.resize(a + 1);
    for (i = 1; i <= a; ++i)
    {
        cin >> lista[i];
    }
    x.resize(n + 1);
    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        x[a].sz.push_back(b);
        x[b].sz.push_back(a);
    }
    lista.pop_front();

    while (!lista.empty())
    {
        x[lista.front()].kezd = true;
        v.push_back(lista.front());
        x[lista.front()].lat = lista.front();
        if (abs(x[lista.front()].minlep)==1 && x[lista.front()].lat) megold.push_back(lista.front());
        x[lista.front()].lep = 0;
        lista.pop_front();
        while (!v.empty())
        {
            akt = v.front();
            v.pop_front();
            for (auto& e : x[akt].sz)
            {
                if (x[e].lat != x[akt].lat)
                {
                    x[e].lat = x[akt].lat;
                    x[e].lep = x[akt].lep + 1;
                    v.push_back(e);
                    if (!x[e].minlep && !x[e].kezd) x[e].minlep = x[e].lep;
                    else if (!x[e].minlep && x[e].kezd && x[e].lep <= 1) megold.push_back(e);
                    else
                    {
                        if (abs(x[e].minlep - x[e].lep) <= 1) megold.push_back(e);
                    }
                }
            }
        }
    }
    sort(megold.begin(), megold.end());
    cout << megold.size() << "\n";
    for (auto& e : megold) cout << e << " ";
    return 0;
}
/*
6 8 2
4 3
6 5
3 1
4 5
4 6
1 6
3 6
5 2
1 4

8 9 3
3 8 6
5 8
8 2
6 5
3 4
3 7
3 5
3 6
1 8
4 1

6 6 2
1 5
1 5
5 4
4 3
3 1
1 2
2 6
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1876 KiB
2Wrong answer0/03ms2068 KiB
3Wrong answer0/03ms2332 KiB
4Wrong answer0/23ms2416 KiB
5Wrong answer0/23ms2636 KiB
6Wrong answer0/23ms2820 KiB
7Wrong answer0/23ms3040 KiB
8Wrong answer0/23ms3128 KiB
9Wrong answer0/23ms3256 KiB
10Wrong answer0/23ms3608 KiB
11Wrong answer0/13ms3792 KiB
12Wrong answer0/23ms4036 KiB
13Wrong answer0/23ms4356 KiB
14Wrong answer0/23ms4444 KiB
15Wrong answer0/24ms4332 KiB
16Wrong answer0/23ms4200 KiB
17Wrong answer0/23ms4288 KiB
18Wrong answer0/14ms4280 KiB
19Wrong answer0/14ms4208 KiB
20Wrong answer0/14ms4224 KiB
21Wrong answer0/18ms4408 KiB
22Wrong answer0/17ms4260 KiB
23Wrong answer0/16ms4260 KiB
24Wrong answer0/16ms4264 KiB
25Wrong answer0/18ms4432 KiB
26Wrong answer0/18ms4428 KiB
27Wrong answer0/14ms4208 KiB
28Wrong answer0/14ms4216 KiB
29Wrong answer0/14ms4212 KiB
30Wrong answer0/14ms4280 KiB
31Wrong answer0/14ms4476 KiB
32Wrong answer0/16ms4604 KiB
33Wrong answer0/152ms6052 KiB
34Wrong answer0/13ms4524 KiB
35Wrong answer0/14ms4528 KiB
36Wrong answer0/14ms4596 KiB
37Wrong answer0/14ms4544 KiB
38Wrong answer0/14ms4552 KiB
39Wrong answer0/14ms4576 KiB
40Wrong answer0/127ms5420 KiB