233242026-01-19 13:40:02markfsibianFertőzési sorozat (50 pont)cpp17Wrong answer 0/5030ms664 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;

vector<int> ism;

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)
        cout << c << " ";
}


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);
    }
    
   
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/08ms512 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/22ms316 KiB
6Wrong answer0/28ms436 KiB
7Wrong answer0/28ms436 KiB
8Wrong answer0/28ms316 KiB
9Wrong answer0/28ms440 KiB
10Wrong answer0/229ms472 KiB
11Wrong answer0/12ms316 KiB
12Wrong answer0/223ms540 KiB
13Wrong answer0/225ms508 KiB
14Wrong answer0/220ms468 KiB
15Wrong answer0/223ms316 KiB
16Wrong answer0/225ms500 KiB
17Wrong answer0/220ms316 KiB
18Wrong answer0/123ms316 KiB
19Wrong answer0/125ms404 KiB
20Wrong answer0/120ms464 KiB
21Wrong answer0/129ms476 KiB
22Wrong answer0/128ms464 KiB
23Wrong answer0/129ms316 KiB
24Wrong answer0/128ms504 KiB
25Wrong answer0/127ms316 KiB
26Wrong answer0/128ms316 KiB
27Wrong answer0/129ms512 KiB
28Wrong answer0/128ms316 KiB
29Wrong answer0/130ms316 KiB
30Wrong answer0/128ms316 KiB
31Wrong answer0/128ms500 KiB
32Wrong answer0/128ms544 KiB
33Wrong answer0/129ms316 KiB
34Wrong answer0/129ms316 KiB
35Wrong answer0/129ms664 KiB
36Wrong answer0/129ms336 KiB
37Wrong answer0/129ms316 KiB
38Wrong answer0/129ms316 KiB
39Wrong answer0/129ms316 KiB
40Wrong answer0/130ms508 KiB