76532024-01-10 10:39:05gonterarminA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 0/5013ms4084 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int v[n][2];
    for (int i=0;i<n;i++) {
        cin>>v[i][0]>>v[i][1];
    }
    int ap=1,ape,db=0;
    vector<int> von;
    while (ap!=m) {
        ape=ap;
        vector<int> s;
        for (int i=0;i<n;i++) {
            if (ap>=v[i][0] && ap<v[i][1]) s.push_back(v[i][1]);
        }
        sort(s.begin(),s.end());
        ap=s[s.size()-1];
        if(ap==ape) {
            cout<<-1;
            return 0;
        }
        for(int i=0;i<n;i++) {
            if (v[i][1]==ap) {von.push_back(i+1); break;}
        }
        db++;
    }
    cout<<db<<endl;
    for (int i=0;i<db;i++) cout<<von[i]<<" ";
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1808 KiB
2Wrong answer0/013ms2268 KiB
3Runtime error0/13ms2456 KiB
4Runtime error0/13ms2820 KiB
5Wrong answer0/23ms2744 KiB
6Wrong answer0/23ms3068 KiB
7Wrong answer0/23ms3148 KiB
8Wrong answer0/24ms3148 KiB
9Wrong answer0/24ms3232 KiB
10Wrong answer0/24ms3348 KiB
11Wrong answer0/26ms3312 KiB
12Wrong answer0/27ms3320 KiB
13Wrong answer0/23ms3480 KiB
14Wrong answer0/24ms3500 KiB
15Wrong answer0/24ms3508 KiB
16Wrong answer0/27ms3524 KiB
17Wrong answer0/29ms3536 KiB
18Wrong answer0/210ms3548 KiB
19Wrong answer0/212ms3740 KiB
20Wrong answer0/212ms3736 KiB
21Wrong answer0/213ms3744 KiB
22Wrong answer0/213ms3788 KiB
23Wrong answer0/29ms4044 KiB
24Wrong answer0/28ms3944 KiB
25Wrong answer0/28ms3940 KiB
26Wrong answer0/29ms3980 KiB
27Wrong answer0/28ms3944 KiB
28Wrong answer0/28ms4084 KiB