35632023-03-01 07:27:341478Adószedőcpp17Wrong answer 0/30216ms13288 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    //ifstream cin("in.txt");
    int n;
    cin >> n;
    int m;
    cin >> m;
    int k;
    cin >> k;
    vector<vector<int>> liszt(n + 1);
    for(int i = 1; i <= m; i++){
        int ferenc1;
        cin >> ferenc1;
        int ferenc2;
        cin >> ferenc2;

        liszt[ferenc1].push_back(ferenc2);
        liszt[ferenc2].push_back(ferenc1);
    }

    /*
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < liszt[i].size(); j++){
            cout << liszt[i][j] << " ";
        }
        cout << '\n';
    }
    */



    vector<int> d(n + 1);
    queue<int> q;
    q.push(k);

    while(!q.empty()){
        int a;
        a = q.front();
        q.pop();
        for(int i = 0; i < liszt[a].size(); i++){
            if(d[liszt[a][i]] == 0 && liszt[a][i]!=k){
                cout<<a<<" "<<liszt[a][i]<<'\n';
                d[liszt[a][i]] = d[a] + 1;
                q.push(liszt[a][i]);
            }
            else if(d[liszt[a][i]] >= d[a]+1){
                cout<<a<<" "<<liszt[a][i]<<'\n';
            }

        }
    }






    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/30
1Wrong answer0/03ms1812 KiB
2Wrong answer0/0165ms9776 KiB
3Wrong answer0/13ms2412 KiB
4Wrong answer0/13ms2480 KiB
5Wrong answer0/13ms2696 KiB
6Wrong answer0/13ms2904 KiB
7Wrong answer0/13ms3112 KiB
8Wrong answer0/13ms3232 KiB
9Wrong answer0/23ms3352 KiB
10Wrong answer0/24ms3368 KiB
11Wrong answer0/24ms3620 KiB
12Wrong answer0/214ms4196 KiB
13Wrong answer0/232ms4856 KiB
14Wrong answer0/2136ms9756 KiB
15Wrong answer0/1190ms12700 KiB
16Wrong answer0/1155ms11000 KiB
17Wrong answer0/2216ms12688 KiB
18Wrong answer0/2177ms11840 KiB
19Wrong answer0/2192ms12464 KiB
20Wrong answer0/2196ms13040 KiB
21Wrong answer0/2202ms13288 KiB