76172024-01-10 09:10:19AGergoA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 4/504ms5180 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
cin.tie(0);
iostream::sync_with_stdio(0);
bool hasStart=false,hasEnd=false;
int vonatszam, allomasszam, current = 1, maxLength, maxID, id=0,num=-1;

cin >> vonatszam >> allomasszam;

vector<int> vonatStart(vonatszam);
vector<int> vonatEnd(vonatszam);
vector<int> valasz;

for(int i = 0; i< vonatszam; i++)
{
    cin >> vonatStart[i] >> vonatEnd[i];
    if(vonatStart[i] == 1)
    {
        hasStart = true;
    }

    if(vonatEnd[i] == allomasszam)
    {
        hasEnd = true;
    }
}
if(hasStart == false || hasEnd == false)
{
    cout << "-1";
}
else
{
    while(current != allomasszam)
    {

        if(vonatStart[id] <= current && vonatEnd[id]>maxLength)
        {
            maxID = id;
            maxLength = vonatEnd[id];
        }
        else if (vonatStart[id] > current)
        {
            if(maxLength == current)
            {
                cout << "-1";
                hasEnd = false;
                break;

            }
        num++;
        current = maxLength;
        valasz.push_back(maxID);
        id--;
        }
        id++;
    }
    if(hasEnd == true)
    {
        for(int asd:valasz)
        {
            cout << asd+1 << " ";
        }
    }
}


}
SubtaskSumTestVerdictTimeMemory
base4/50
1Wrong answer0/03ms1976 KiB
2Wrong answer0/04ms2388 KiB
3Accepted1/13ms2544 KiB
4Accepted1/13ms2528 KiB
5Wrong answer0/23ms2740 KiB
6Wrong answer0/23ms2912 KiB
7Wrong answer0/23ms3148 KiB
8Wrong answer0/23ms3356 KiB
9Wrong answer0/23ms3396 KiB
10Wrong answer0/23ms3744 KiB
11Wrong answer0/24ms3832 KiB
12Wrong answer0/24ms3776 KiB
13Wrong answer0/23ms3740 KiB
14Wrong answer0/23ms4024 KiB
15Wrong answer0/23ms4028 KiB
16Wrong answer0/24ms4244 KiB
17Wrong answer0/24ms4208 KiB
18Wrong answer0/24ms4524 KiB
19Wrong answer0/24ms4760 KiB
20Wrong answer0/24ms4648 KiB
21Wrong answer0/24ms4680 KiB
22Wrong answer0/24ms4668 KiB
23Runtime error0/24ms5040 KiB
24Runtime error0/24ms5000 KiB
25Partially correct1/24ms5180 KiB
26Runtime error0/24ms5180 KiB
27Runtime error0/24ms5168 KiB
28Partially correct1/24ms5068 KiB