233252026-01-19 13:41:51markfsibianFertőzési sorozat (50 pont)cpp17Wrong answer 2/5029ms508 KiB
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

#define f(l,j,k) for (int i = l; i <= j; i = i + k)

struct csp
{
    bool lat;
    int lep;
    vector<int> sz;
};

int n, m, k, c, a, akt, s;


vector<int> ism;
vector<int> meg;

vector<csp> x;
deque<int> v;

void bejar(vector<csp> x, int a, int b, int c)
{
    int kezd = c;
    v.push_back(kezd);
    x[kezd].lat = true;
    x[kezd].lep = 1;

    while (!v.empty())
    {
        akt = v.front();
        v.pop_front();
        for (auto& e : x[akt].sz)
        {
            if (!x[e].lat)
            {
                v.push_back(e);
                x[e].lat = 1;
                x[e].lep = x[akt].lep + 1;
            }
        }
    }
    if (abs(x[a].lep - x[b].lep) <= 1)
    {
        meg.push_back(c);
        s++;
    }
}


int main()
{
    cin >> n >> m >> k;

    x.resize(n + 1);
    
    f(1, k, 1)
    {
        cin >> c;
        ism.push_back(c);
    }

    f(1, m, 1)
    {
        cin >> a >> c;
        x[a].sz.push_back(c);
        x[c].sz.push_back(a);
    }

    f(1, n, 1)
    {
        bejar(x, ism[0], ism[1], i);
    }
    
    cout << s << endl;

    for (auto& e : meg)
        cout << e << " ";

   
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms492 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/08ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/22ms316 KiB
6Wrong answer0/28ms432 KiB
7Wrong answer0/28ms436 KiB
8Wrong answer0/28ms316 KiB
9Wrong answer0/28ms436 KiB
10Wrong answer0/229ms468 KiB
11Wrong answer0/12ms508 KiB
12Wrong answer0/223ms316 KiB
13Accepted2/224ms468 KiB
14Wrong answer0/221ms316 KiB
15Wrong answer0/223ms316 KiB
16Wrong answer0/224ms460 KiB
17Wrong answer0/220ms468 KiB
18Wrong answer0/123ms468 KiB
19Wrong answer0/124ms500 KiB
20Wrong answer0/120ms460 KiB
21Wrong answer0/128ms476 KiB
22Wrong answer0/128ms464 KiB
23Wrong answer0/128ms316 KiB
24Wrong answer0/128ms316 KiB
25Wrong answer0/127ms316 KiB
26Wrong answer0/128ms316 KiB
27Wrong answer0/128ms472 KiB
28Wrong answer0/128ms508 KiB
29Wrong answer0/128ms472 KiB
30Wrong answer0/128ms316 KiB
31Wrong answer0/128ms316 KiB
32Wrong answer0/128ms480 KiB
33Wrong answer0/129ms500 KiB
34Wrong answer0/128ms316 KiB
35Wrong answer0/128ms464 KiB
36Wrong answer0/129ms316 KiB
37Wrong answer0/128ms464 KiB
38Wrong answer0/128ms472 KiB
39Wrong answer0/128ms316 KiB
40Wrong answer0/129ms468 KiB