72832024-01-06 08:59:53MagyarKendeSZLGA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 1/504ms3948 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define size(v) (int)v.size()
#define has(s, e) s.count(e)

#define max_index(v) max_element(all(v)) - v.begin()
#define min_index(v) min_element(all(v)) - v.begin()
#define smax(x, y) x = max(x, y)
#define smin(x, y) x = min(x, y)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int max(point p) { return max(p[0], p[1]); }
int min(point p) { return min(p[0], p[1]); }

int main() {
    speed;

    int N, M;
    cin >> N >> M;
    
    vector<point> AB(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> AB[i][0] >> AB[i][1];
    }

    vector<int> result;
    int i = i, pos = 1;

    while (pos < M) {
        int curr = -1;

        while (i <= N && AB[i][0] <= pos) {
            if (curr == -1 || AB[curr][1] < AB[i][1]) {
                curr = i++;
            }
        }

        if (curr == -1) {
            cout << -1;
            exit(0);
        }

        pos = AB[curr][1];
        result.push_back(curr);
    }

    cout << size(result) << '\n';
    for (int x : result) cout << x << ' ';
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Wrong answer0/03ms1824 KiB
2Runtime error0/04ms2332 KiB
3Accepted1/13ms2328 KiB
4Runtime error0/13ms2548 KiB
5Wrong answer0/23ms2652 KiB
6Wrong answer0/22ms2740 KiB
7Runtime error0/23ms2984 KiB
8Wrong answer0/23ms2968 KiB
9Runtime error0/23ms3076 KiB
10Runtime error0/23ms3084 KiB
11Runtime error0/24ms3364 KiB
12Wrong answer0/24ms3228 KiB
13Runtime error0/23ms3324 KiB
14Wrong answer0/23ms3460 KiB
15Wrong answer0/23ms3388 KiB
16Runtime error0/24ms3552 KiB
17Wrong answer0/24ms3588 KiB
18Wrong answer0/24ms3528 KiB
19Runtime error0/24ms3632 KiB
20Runtime error0/24ms3640 KiB
21Runtime error0/24ms3640 KiB
22Runtime error0/24ms3640 KiB
23Wrong answer0/24ms3536 KiB
24Runtime error0/24ms3644 KiB
25Runtime error0/24ms3648 KiB
26Wrong answer0/24ms3540 KiB
27Runtime error0/24ms3652 KiB
28Runtime error0/24ms3948 KiB