94812024-02-22 10:42:52csaron71A lehető legkevesebb metróval utazás (40 pont)cpp17Wrong answer 2/4057ms63532 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, kezd, veg;
    cin >> n >> m >> kezd >> veg;
    kezd--;
    veg--;
    vector<vector<int> > graph(m, vector<int>());
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        vector<int> epp;
        for (int j=0; j<x; j++) {
            int y;
            cin >> y;
            y--;
            epp.push_back(y);
        }
        for (int q=0; q<x; q++) {
            for (int j=q+1; j<x; j++) {
                graph[epp[q]].push_back(epp[j]);
                graph[epp[j]].push_back(epp[q]);
            }
        }
    }

    queue<pair<int, int> > sor;
    vector<bool> volt(m, false);
    vector<int> tav(m, -1);
    sor.push({kezd, 0});
    tav[kezd]=0;
/*
    while (sor.size()>0) {
        int elso=sor.front().first;
        int hany=sor.front().second;
        sor.pop();
        if (volt[elso]==true) continue;
        tav[elso]=hany;
        volt[elso]=true;

        for (int sz : graph[elso]) {
            if (volt[sz]!=true) {
                sor.push({sz, hany+1});
            }
        }
    }*/
/*
    for (int sz : tav) {
        cout << sz << " ";
    }*/
    cout << tav[veg];
}
SubtaskSumTestVerdictTimeMemory
base2/40
1Wrong answer0/03ms1816 KiB
2Wrong answer0/017ms13420 KiB
3Wrong answer0/23ms2400 KiB
4Wrong answer0/23ms2480 KiB
5Wrong answer0/24ms5460 KiB
6Accepted2/23ms2808 KiB
7Wrong answer0/212ms16200 KiB
8Wrong answer0/217ms22348 KiB
9Wrong answer0/234ms45728 KiB
10Wrong answer0/223ms26528 KiB
11Wrong answer0/26ms6000 KiB
12Wrong answer0/219ms17248 KiB
13Wrong answer0/218ms17220 KiB
14Wrong answer0/217ms15728 KiB
15Runtime error0/254ms63532 KiB
16Runtime error0/257ms63296 KiB
17Runtime error0/250ms63060 KiB
18Runtime error0/252ms62984 KiB
19Wrong answer0/210ms9204 KiB
20Wrong answer0/216ms13848 KiB
21Wrong answer0/26ms6200 KiB
22Wrong answer0/217ms15436 KiB