40962023-03-14 12:32:08DragonoidOmegaA lehető legkevesebb átszállás (50 pont)cpp11Runtime error 49/5059ms64536 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(i<=n && x[i].F<=veg)
        {
            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/03ms1808 KiB
2Accepted0/08ms2272 KiB
3Accepted1/13ms2340 KiB
4Runtime error0/159ms64536 KiB
5Accepted2/23ms2544 KiB
6Accepted2/23ms2640 KiB
7Accepted2/23ms3156 KiB
8Accepted2/24ms3124 KiB
9Accepted2/24ms3508 KiB
10Accepted2/24ms3364 KiB
11Accepted2/24ms3648 KiB
12Accepted2/26ms3552 KiB
13Accepted2/23ms3512 KiB
14Accepted2/24ms3728 KiB
15Accepted2/24ms3840 KiB
16Accepted2/26ms3836 KiB
17Accepted2/27ms4116 KiB
18Accepted2/28ms4212 KiB
19Accepted2/28ms4068 KiB
20Accepted2/28ms4080 KiB
21Accepted2/28ms4212 KiB
22Accepted2/28ms4228 KiB
23Accepted2/28ms4224 KiB
24Accepted2/28ms4484 KiB
25Accepted2/28ms4436 KiB
26Accepted2/28ms4572 KiB
27Accepted2/28ms4724 KiB
28Accepted2/28ms4580 KiB