93332024-02-20 14:48:03AGergoHálózati átvitelcpp17Wrong answer 2/50651ms62880 KiB
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> graf; //graf[a][b] -> a b közti sebesség
//vector<bool> used; // használt-e már adott pont
vector<vector<int>> ut; // [a][b] -> K-ból a-ba menõ út b lépésben legnagyobb gyorsasága
vector<vector<int>> available; //osszes hely avoha lehet menni (adott vektorból)
int maxLepes;

void bejar(int id,int speed, int steps)
{
    steps++;
    if(steps <= maxLepes)
    {
        for(int i: available[id])
        {
            int spd = graf[id][i];
            if(speed > spd)
            {
                //speed = spd;ssss
            }
            else
            {
                spd = speed;
            }
            if(spd > ut[i][steps])
            {
                ut[i][steps] = spd;
            }

            //cout << id << "->" << i << ": " << spd << ":" << speed << endl;
            bejar(i,spd,steps);
        }
    }
}


int main()
{
    iostream::sync_with_stdio(0);cin.tie(0);

    //dijkstra csak minden utat eltárolsz
    int csomo,vonal,koz;
    cin >> csomo >> vonal >> koz >> maxLepes;

    graf.resize(csomo+1,vector<int>(csomo+1));
    available.resize(csomo+1);

    int p1,p2,v;
    for(int i = 0; i < vonal; i++)
    {
        cin >> p1 >> p2 >> v;
        graf[p1][p2] = v;
        graf[p2][p1] = v;

        available[p1].resize(available[p1].size()+1);
        available[p1][available[p1].size()-1] = p2;

        available[p2].resize(available[p2].size()+1);
        available[p2][available[p2].size()-1] = p1;
    }

    //used.resize(csomo+1,false);
    ut.resize(csomo+1,vector<int>(maxLepes+1,-1));

    bejar(koz,100001,0);
    int highest;

    //cout << "-----------------------\n";
    for(int i = 1;i <= csomo;i++)
    {
        if(i == koz)
        {
            cout << "0\n";
        }
        else
        {
            highest = 0;
            for(int x: ut[i])
            {
                //cout << x << ":";
                if( x > highest )
                {
                    highest = x;
                }
            }
            cout << highest <<"\n";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/03ms1828 KiB
2Accepted0/0123ms2400 KiB
3Wrong answer0/13ms2232 KiB
4Wrong answer0/13ms2436 KiB
5Accepted2/2370ms2732 KiB
6Time limit exceeded0/2570ms2012 KiB
7Time limit exceeded0/2638ms3260 KiB
8Time limit exceeded0/2561ms3340 KiB
9Time limit exceeded0/1561ms6768 KiB
10Time limit exceeded0/1555ms6864 KiB
11Time limit exceeded0/1565ms7364 KiB
12Time limit exceeded0/1566ms7600 KiB
13Time limit exceeded0/2570ms7748 KiB
14Time limit exceeded0/2555ms7788 KiB
15Time limit exceeded0/2565ms8000 KiB
16Time limit exceeded0/2555ms7948 KiB
17Time limit exceeded0/2651ms8116 KiB
18Time limit exceeded0/2574ms8604 KiB
19Time limit exceeded0/2563ms8756 KiB
20Time limit exceeded0/2570ms8732 KiB
21Runtime error0/126ms62880 KiB
22Runtime error0/128ms62640 KiB
23Runtime error0/134ms62596 KiB
24Runtime error0/132ms62504 KiB
25Runtime error0/228ms62492 KiB
26Runtime error0/232ms62460 KiB
27Runtime error0/232ms62320 KiB
28Runtime error0/229ms62312 KiB
29Runtime error0/228ms62080 KiB
30Runtime error0/229ms62076 KiB
31Runtime error0/232ms62052 KiB
32Runtime error0/229ms62024 KiB