40792023-03-13 08:40:34DragonoidOmegaA lehető legkevesebb átszállás (50 pont)cpp11Runtime error 49/5056ms64424 KiB
#include <iostream>
#include <vector>
#include <queue>


#define F first
#define S second


using namespace std;

queue <int> q;
int n,veg,i,maxi,m,fe;

int main()
{
    cin>>n>>m;
    vector <pair <int,int> > x(n+1);

    for(i=1;i<=n;++i)
    {
        cin>>x[i].F>>x[i].S;
    }

    veg=1;
    i=1;
    while(i<=n)
    {
        while(x[i].F<=veg && i<=n)
        {
            if(maxi<x[i].S)
            {
                maxi=x[i].S;
                fe=i;
            }
            ++i;
        }
        veg=maxi;
        q.push(fe);
        if(veg==m)
        {
            cout<<q.size()-1<<"\n";
            while(!q.empty())
            {
                cout<<q.front()<<" ";
                q.pop();
            }
            return 0;
        }
    }
    cout<<-1;

}
SubtaskSumTestVerdictTimeMemory
base49/50
1Accepted0/03ms1812 KiB
2Accepted0/08ms2212 KiB
3Accepted1/13ms2216 KiB
4Runtime error0/156ms64424 KiB
5Accepted2/23ms2548 KiB
6Accepted2/23ms2624 KiB
7Accepted2/23ms2760 KiB
8Accepted2/23ms2976 KiB
9Accepted2/24ms3212 KiB
10Accepted2/24ms3280 KiB
11Accepted2/24ms3508 KiB
12Accepted2/26ms3508 KiB
13Accepted2/23ms3476 KiB
14Accepted2/24ms3612 KiB
15Accepted2/24ms3716 KiB
16Accepted2/26ms3976 KiB
17Accepted2/27ms4328 KiB
18Accepted2/28ms4168 KiB
19Accepted2/28ms4424 KiB
20Accepted2/28ms4392 KiB
21Accepted2/28ms4420 KiB
22Accepted2/28ms4476 KiB
23Accepted2/28ms4472 KiB
24Accepted2/28ms4580 KiB
25Accepted2/28ms4428 KiB
26Accepted2/28ms4688 KiB
27Accepted2/28ms4600 KiB
28Accepted2/28ms4608 KiB