30052023-02-08 09:39:47bzsofiaAdószedőcpp11Hibás válasz 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base3/30
1Hibás válasz0/03ms1812 KiB
2Futási hiba0/034ms64832 KiB
3Elfogadva1/13ms2292 KiB
4Hibás válasz0/13ms2488 KiB
5Hibás válasz0/13ms2568 KiB
6Hibás válasz0/13ms2696 KiB
7Hibás válasz0/13ms2900 KiB
8Hibás válasz0/13ms3016 KiB
9Elfogadva2/24ms3656 KiB
10Hibás válasz0/24ms3752 KiB
11Hibás válasz0/24ms3876 KiB
12Hibás válasz0/214ms8380 KiB
13Hibás válasz0/237ms30996 KiB
14Futási hiba0/232ms63444 KiB
15Futási hiba0/128ms63200 KiB
16Futási hiba0/128ms62964 KiB
17Futási hiba0/227ms62936 KiB
18Futási hiba0/232ms62916 KiB
19Futási hiba0/232ms62676 KiB
20Futási hiba0/232ms62652 KiB
21Futási hiba0/227ms62648 KiB