97262024-03-04 10:45:49tamasmarkFertőzési sorozat (50 pont)cpp17Wrong answer 0/5054ms5604 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;
    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())
    {
        v.push_back(lista.front());
        x[lista.front()].lat = 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].minlep = x[e].lep;
                    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
*/
// 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/03ms1872 KiB
2Wrong answer0/03ms2120 KiB
3Wrong answer0/03ms2452 KiB
4Wrong answer0/23ms2548 KiB
5Wrong answer0/23ms2704 KiB
6Wrong answer0/23ms2792 KiB
7Wrong answer0/23ms3056 KiB
8Wrong answer0/23ms3056 KiB
9Wrong answer0/23ms3256 KiB
10Wrong answer0/23ms3352 KiB
11Wrong answer0/13ms3524 KiB
12Wrong answer0/23ms3596 KiB
13Wrong answer0/23ms3596 KiB
14Wrong answer0/23ms3600 KiB
15Wrong answer0/23ms3608 KiB
16Wrong answer0/23ms3604 KiB
17Wrong answer0/23ms3604 KiB
18Wrong answer0/14ms3692 KiB
19Wrong answer0/14ms3604 KiB
20Wrong answer0/14ms3748 KiB
21Wrong answer0/18ms3908 KiB
22Wrong answer0/17ms3724 KiB
23Wrong answer0/16ms3708 KiB
24Wrong answer0/16ms3712 KiB
25Wrong answer0/18ms3892 KiB
26Wrong answer0/18ms4012 KiB
27Wrong answer0/14ms3796 KiB
28Wrong answer0/14ms3796 KiB
29Wrong answer0/14ms3872 KiB
30Wrong answer0/14ms3940 KiB
31Wrong answer0/14ms3812 KiB
32Wrong answer0/16ms4144 KiB
33Wrong answer0/154ms5604 KiB
34Wrong answer0/13ms4072 KiB
35Wrong answer0/14ms4084 KiB
36Wrong answer0/14ms4080 KiB
37Wrong answer0/14ms4088 KiB
38Wrong answer0/14ms4100 KiB
39Wrong answer0/14ms4368 KiB
40Wrong answer0/128ms5196 KiB