178442025-09-19 17:42:38KristófA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 6/508ms592 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> utak(n+1);
    for(int i=1;i<=n;i++)
        {
        cin>>utak[i].first>>utak[i].second;
        }
    int tovabbm=1;
    int tovabbmtmp=1;
    int indextmp;
    vector<int> megoldas(10001);
    int cnt=0;
    for(int i=1;i<=n;)
        {
        if(utak[i].first<=tovabbm)
            {
            if(utak[i].second>tovabbmtmp)
                {
                tovabbmtmp=utak[i].second;
                indextmp=i;
                }
            i++;
            }
        else
            {
            if(tovabbm==tovabbmtmp)
                {
                cout<<-1<<" "<<tovabbm;
                return 0;
                }
            else
                {
                tovabbm=tovabbmtmp;
                megoldas[cnt]=indextmp;
                cnt++;
                }
            }
        }
    cout<<cnt<<endl;
    for(int i=0;i<cnt;i++)
        {
        cout<<megoldas[i]<<" ";
        }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/08ms564 KiB
3Wrong answer0/11ms316 KiB
4Accepted1/11ms316 KiB
5Wrong answer0/21ms500 KiB
6Partially correct1/21ms508 KiB
7Wrong answer0/22ms572 KiB
8Wrong answer0/22ms508 KiB
9Wrong answer0/22ms508 KiB
10Wrong answer0/23ms440 KiB
11Wrong answer0/24ms316 KiB
12Wrong answer0/24ms484 KiB
13Wrong answer0/22ms316 KiB
14Wrong answer0/22ms316 KiB
15Wrong answer0/23ms464 KiB
16Wrong answer0/24ms412 KiB
17Wrong answer0/26ms536 KiB
18Wrong answer0/26ms564 KiB
19Wrong answer0/27ms564 KiB
20Wrong answer0/27ms568 KiB
21Wrong answer0/28ms416 KiB
22Wrong answer0/28ms568 KiB
23Partially correct1/27ms580 KiB
24Partially correct1/27ms584 KiB
25Wrong answer0/28ms564 KiB
26Partially correct1/28ms592 KiB
27Partially correct1/28ms496 KiB
28Wrong answer0/28ms588 KiB