30052023-02-08 09:39:47bzsofiaAdószedőcpp11Wrong answer 3/3037ms64832 KiB
// Adoszedo.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct adat
{
    int tav;
    bool lat;
    vector <int> sz;
};

int i, n, m, a, b, kezd, akt;
queue <int> s;
vector <pair<int, int>> v;

int main()
{
    cin >> n >> m >> kezd;
    vector <adat> x(n + 1);
    vector <vector <bool>> el(n + 1, vector <bool>(n + 1));

    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b;

        x[a].sz.push_back(b);
        x[b].sz.push_back(a);
    }

    x[kezd].lat = 1;
    s.push(kezd);
    while (!s.empty())
    {
        akt = s.front();
        //cout << akt << " ";
        s.pop();
        for (auto& e : x[akt].sz)
        {
            if (!x[e].lat)
            {
                s.push(e);
                x[e].lat = 1;
                if (!el[e][akt])
                {
                    v.push_back({ akt,e });
                }
                el[e][akt] = el[akt][e] = 1;
                x[e].tav = x[akt].tav+1;
            }
        }
    }

    //cout << x[n].tav;

    cout << v.size() << "\n";
    for (auto& e : v)
    {
        cout << e.first << " " << e.second << "\n";
    }

    return 0;
}

// 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
base3/30
1Wrong answer0/03ms1812 KiB
2Runtime error0/034ms64832 KiB
3Accepted1/13ms2292 KiB
4Wrong answer0/13ms2488 KiB
5Wrong answer0/13ms2568 KiB
6Wrong answer0/13ms2696 KiB
7Wrong answer0/13ms2900 KiB
8Wrong answer0/13ms3016 KiB
9Accepted2/24ms3656 KiB
10Wrong answer0/24ms3752 KiB
11Wrong answer0/24ms3876 KiB
12Wrong answer0/214ms8380 KiB
13Wrong answer0/237ms30996 KiB
14Runtime error0/232ms63444 KiB
15Runtime error0/128ms63200 KiB
16Runtime error0/128ms62964 KiB
17Runtime error0/227ms62936 KiB
18Runtime error0/232ms62916 KiB
19Runtime error0/232ms62676 KiB
20Runtime error0/232ms62652 KiB
21Runtime error0/227ms62648 KiB