99072024-03-18 15:03:51VargusKerékpártúra (50 pont)cpp17Wrong answer 16/50141ms11108 KiB
#include <iostream>
#include <queue>
#include <climits>
#define ll long long

using namespace std;

struct adat
{
    bool lat = false, utak = false;
    ll honnan = INT_MAX;
    vector <ll> sz;
};
vector <adat> x;
deque <ll> ut, vissza;

ll kezd;
void melyseg(ll csp)
{
    x[csp].lat = true;
    for (auto& e : x[csp].sz)
    {
        if (!x[e].lat)
        { 
            x[e].honnan = csp;
            melyseg(e);
        }
        if (e == kezd)
            vissza.push_front(csp);
    }
}

int main()
{
    ll csp, el;
    cin >> csp >> el >> kezd;
    x.resize(csp + 1);
    for (ll i = 1; i <= el; ++i)
    {
        ll cs1, cs2;
        cin >> cs1 >> cs2;
        x[cs1].sz.push_back(cs2);
    }
    melyseg(kezd);

    ll akt = 0;
    x[kezd].utak = true;
    for (auto& e : vissza)
    {
        akt = vissza.front();
        vissza.pop_front();
        while (akt != kezd)
        {
            x[akt].utak = true;
            ut.push_front(akt);
            for (auto& f : x[akt].sz)
            {
                if (!x[f].utak)
                {
                    x[f].utak = true;
                    ut.push_front(f);
                }
            }
            akt = x[akt].honnan;
        }
    }
    cout << ut.size() << endl;
    for (auto& e : ut)
        cout << e << " ";

    return 0;
}

SubtaskSumTestVerdictTimeMemory
base16/50
1Accepted0/03ms1684 KiB
2Wrong answer0/021ms3720 KiB
3Wrong answer0/23ms2068 KiB
4Accepted2/23ms2304 KiB
5Accepted2/23ms2520 KiB
6Wrong answer0/23ms2768 KiB
7Wrong answer0/23ms2828 KiB
8Wrong answer0/24ms3088 KiB
9Wrong answer0/24ms3328 KiB
10Accepted2/24ms3396 KiB
11Wrong answer0/27ms3744 KiB
12Wrong answer0/213ms4000 KiB
13Wrong answer0/214ms4184 KiB
14Wrong answer0/224ms4948 KiB
15Wrong answer0/335ms6300 KiB
16Wrong answer0/437ms6676 KiB
17Accepted4/454ms7260 KiB
18Accepted3/348ms7132 KiB
19Accepted3/341ms6740 KiB
20Wrong answer0/3134ms10136 KiB
21Wrong answer0/3138ms10640 KiB
22Wrong answer0/3141ms11108 KiB