76552024-01-10 10:44:19gonterarminA lehető legkevesebb átszállás (50 pont)cpp14Wrong answer 0/5013ms3940 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/03ms1816 KiB
2Wrong answer0/013ms2208 KiB
3Runtime error0/13ms2328 KiB
4Runtime error0/13ms2272 KiB
5Wrong answer0/23ms2460 KiB
6Wrong answer0/23ms2440 KiB
7Wrong answer0/23ms2656 KiB
8Wrong answer0/23ms2612 KiB
9Wrong answer0/24ms2860 KiB
10Wrong answer0/24ms3092 KiB
11Wrong answer0/26ms3160 KiB
12Wrong answer0/27ms3180 KiB
13Wrong answer0/23ms3280 KiB
14Wrong answer0/24ms3372 KiB
15Wrong answer0/24ms3484 KiB
16Wrong answer0/27ms3424 KiB
17Wrong answer0/29ms3444 KiB
18Wrong answer0/210ms3452 KiB
19Wrong answer0/212ms3608 KiB
20Wrong answer0/212ms3612 KiB
21Wrong answer0/213ms3760 KiB
22Wrong answer0/213ms3612 KiB
23Wrong answer0/28ms3836 KiB
24Wrong answer0/28ms3792 KiB
25Wrong answer0/28ms3904 KiB
26Wrong answer0/28ms3940 KiB
27Wrong answer0/28ms3792 KiB
28Wrong answer0/28ms3792 KiB