74462024-01-09 08:57:39AblablablaA lehető legkevesebb átszállás (50 pont)cpp14Time limit exceeded 38/50272ms5528 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

int main()
{
    int n, m;
    cin >> m >> n;

    vector<pii> eleri(n);
    int maxi = 0;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        maxi = max(maxi, b);

        for(int j = a; j <= b; j++){
            if(eleri[j].first < b){
                eleri[j].first = b;
                eleri[j].second = i;
            }
        }
    }

    int akt = 0;
    vector<int> vonalak;
    while(akt < n - 1){
        if(akt == eleri[akt].first){
            cout << "-1\n";
            return 0;
        }

        vonalak.push_back(eleri[akt].second);
        akt = eleri[akt].first;
    }

    cout << vonalak.size() - 1 << "\n";
    for(int x : vonalak){
        cout << x + 1 << " ";
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/03ms1812 KiB
2Accepted0/013ms3408 KiB
3Accepted1/13ms2360 KiB
4Accepted1/13ms2592 KiB
5Accepted2/23ms2652 KiB
6Accepted2/23ms2792 KiB
7Accepted2/23ms3060 KiB
8Accepted2/24ms3164 KiB
9Accepted2/24ms3660 KiB
10Accepted2/24ms3464 KiB
11Accepted2/27ms3672 KiB
12Accepted2/28ms3920 KiB
13Accepted2/24ms3992 KiB
14Accepted2/24ms4216 KiB
15Accepted2/26ms4472 KiB
16Accepted2/28ms4596 KiB
17Accepted2/29ms5212 KiB
18Accepted2/210ms5128 KiB
19Accepted2/212ms5404 KiB
20Accepted2/212ms5436 KiB
21Accepted2/213ms5528 KiB
22Accepted2/213ms5320 KiB
23Time limit exceeded0/2272ms3700 KiB
24Time limit exceeded0/2268ms3896 KiB
25Time limit exceeded0/2252ms3896 KiB
26Time limit exceeded0/2264ms4072 KiB
27Time limit exceeded0/2268ms4148 KiB
28Time limit exceeded0/2268ms4168 KiB