73662024-01-08 11:31:33tamasmarkTom és Jerry 1 (80)cpp17Wrong answer 0/80563ms12916 KiB
// tomesjerry.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>

#define ll long long 
using namespace std;

ll n, m, t, p, E;
struct adat
{
    ll bet = 0, bej = 0;
    bool lat = false, latt = false;
    vector<pair<ll, ll>>sz;
};
int main()
{
    cin >> n >> m >> t >> p >> E;
    vector<adat>x(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        x[a].sz.push_back({ b,c });
        x[b].sz.push_back({ a,c });

    }
    deque<ll>v;
    v.push_back(t);
    while (!v.empty())
    {

        ll akt = v.front();
        x[akt].latt = true;
        v.pop_front();
        for (auto& e : x[akt].sz)
        {
            if (!x[e.first].latt && e.second == 2)
            {
                x[e.first].bet = x[akt].bet + 1;
                v.push_back(e.first);
            }
        }


    }

    while (p--)
    {
        ll akt;
        cin >> akt;
        v.push_back(akt);
        while (!v.empty())
        {
            akt = v.front();
            v.pop_front();
            x[akt].lat = true;
            for (auto& e : x[akt].sz)
            {
                if (!x[e.first].lat && (x[e.first].bet > x[akt].lat + 1 || (x[e.first].bet == 0 && e.first != t)))
                {
                    x[e.first].bej = x[akt].bej + 1;
                    v.push_back(e.first);
                }
            }

        }
        if (x[E].lat == true)cout << "IGEN\n";
        else cout << "NEM\n";
        for (int i = 1; i <= n; ++i)
        {
            x[i].bej = 0;
            x[i].lat = false;
        }

    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/80
1Accepted0/03ms1812 KiB
2Wrong answer0/04ms2228 KiB
3Wrong answer0/43ms2212 KiB
4Wrong answer0/43ms2300 KiB
5Wrong answer0/43ms2708 KiB
6Wrong answer0/43ms2660 KiB
7Wrong answer0/43ms2784 KiB
8Wrong answer0/44ms2900 KiB
9Wrong answer0/44ms2900 KiB
10Wrong answer0/44ms3272 KiB
11Wrong answer0/46ms3132 KiB
12Wrong answer0/413ms4812 KiB
13Wrong answer0/421ms4944 KiB
14Wrong answer0/434ms6996 KiB
15Wrong answer0/446ms7112 KiB
16Wrong answer0/493ms12916 KiB
17Wrong answer0/457ms9144 KiB
18Wrong answer0/454ms9144 KiB
19Time limit exceeded0/4563ms6608 KiB
20Time limit exceeded0/4561ms6508 KiB
21Time limit exceeded0/4550ms5672 KiB
22Time limit exceeded0/4550ms5808 KiB