198132025-12-24 00:45:03KristófTom és Jerry 1 (80)cpp17Wrong answer 24/80116ms5756 KiB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int INF=500000;
int main()
{
    int n,m,tom,proba,egerlyuk;
    cin>>n>>m>>tom>>proba>>egerlyuk;
    vector<vector<int>> tomg(n+1);
    vector<vector<int>> jerryg(n+1);
    int from,to,type;
    for(int i=0;i<m;i++)
        {
        cin>>from>>to>>type;
        //cout<<from<<" "<<to<<" "<<type<<"\n";
        if(type==1)
            {
            jerryg[from].push_back(to);
            jerryg[to].push_back(from);
            }
        else
            {
            jerryg[from].push_back(to);
            jerryg[to].push_back(from);
            tomg[from].push_back(to);
            tomg[to].push_back(from);
            }
        }

    vector<int> tomd(n+1,INF);
    vector<bool> visit(n+1,false);
    queue<int> q;
    q.push(tom);visit[tom]=true;tomd[tom]=0;
    while(q.size())
        {
        int v=q.front();q.pop();
        for(int x:tomg[v])
            {
            if(!visit[x])
                {
                visit[x]=true;
                q.push(x);
                tomd[x]=tomd[v]+1;
                }
            }
        }
    vector<int> ans(n+1,INF);
    for(int i=0;i<=n;i++)visit[i]=false;
    q.push(egerlyuk);visit[egerlyuk]=true;ans[egerlyuk]=tomd[egerlyuk]-1;
    while(q.size())
        {
        //cout<<"ALMAAAAAAAAAAA\n";
        int v=q.front();q.pop();
        for(int x:jerryg[v])
            {
            if(!visit[x])
                {
                visit[x]=true;
                q.push(x);
                //cout<<x<<endl;
                ans[x]=min(ans[v]-1,tomd[x]);
                }
            }
        }
    int tmp;
    for(int i=0;i<proba;i++)
        {
        cin>>tmp;
        if(ans[tmp]<0)
            {
            cout<<"NEM\n";
            }
        else
            {
            cout<<"IGEN\n";
            }
        }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base24/80
1Accepted0/01ms316 KiB
2Accepted0/03ms500 KiB
3Accepted4/41ms316 KiB
4Accepted4/41ms500 KiB
5Wrong answer0/41ms316 KiB
6Wrong answer0/41ms316 KiB
7Wrong answer0/41ms316 KiB
8Wrong answer0/42ms316 KiB
9Wrong answer0/43ms332 KiB
10Accepted4/43ms564 KiB
11Wrong answer0/49ms820 KiB
12Accepted4/413ms1424 KiB
13Wrong answer0/421ms1700 KiB
14Wrong answer0/448ms2804 KiB
15Accepted4/464ms3188 KiB
16Accepted4/474ms5756 KiB
17Wrong answer0/4108ms5052 KiB
18Wrong answer0/467ms3924 KiB
19Wrong answer0/486ms4916 KiB
20Wrong answer0/482ms4916 KiB
21Wrong answer0/474ms3636 KiB
22Wrong answer0/4116ms5052 KiB