141472025-01-10 06:15:42madvirA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 4/508ms564 KiB
#include <iostream>
#include <set>

using namespace std;

struct vonat {
    int x, y, ind;
};

int main()
{
    int n, m, x, y;
    cin >> n >> m;
    vonat von[n+1];
    set<int> used;
    for(int i=1; i<=n; i++) {
        cin >> x >> y;
        von[i].x=x;
        von[i].y=y;
        von[i].ind=i;
    }
    int k=2, p=von[1].x, q=von[1].y;
    while(von[k].x==p) {
        q=von[k].y;
        k++;
    }
    used.insert(k-1);
    while(k<=n) {
        if(von[k].x<=q && von[k].y>q) {
            if(p>=von[k].x) {
              used.erase(k-1);
            }
            p=von[k].x;
            q=von[k].y;
            used.insert(von[k].ind);
        }
        k++;
    }
    if(von[1].x!=1 || q!=m) {
      cout << -1;
    }
    else {
      cout << used.size()-1 << endl;
      for(set<int>::iterator ptr=used.begin(); ptr!=used.end(); ptr++) {
         cout << *ptr << " ";
      }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/01ms316 KiB
2Wrong answer0/08ms564 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Wrong answer0/21ms316 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/22ms316 KiB
9Wrong answer0/22ms316 KiB
10Wrong answer0/23ms336 KiB
11Wrong answer0/24ms316 KiB
12Wrong answer0/24ms316 KiB
13Wrong answer0/22ms316 KiB
14Wrong answer0/22ms316 KiB
15Wrong answer0/23ms316 KiB
16Wrong answer0/24ms316 KiB
17Wrong answer0/26ms316 KiB
18Wrong answer0/27ms564 KiB
19Wrong answer0/27ms564 KiB
20Wrong answer0/27ms508 KiB
21Wrong answer0/28ms456 KiB
22Wrong answer0/28ms564 KiB
23Wrong answer0/27ms316 KiB
24Wrong answer0/27ms444 KiB
25Wrong answer0/27ms508 KiB
26Wrong answer0/27ms476 KiB
27Wrong answer0/27ms320 KiB
28Wrong answer0/27ms496 KiB