120742024-11-29 13:11:19RRoliA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 49/509ms1196 KiB
#include <bits/stdc++.h>
using namespace std;

int n, m, a[100001][2], ki[100001];

int main() {
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int e, u;
		cin >> e >> u;
		if(a[e][0] < u) {
			a[e][0] = u;
			a[e][1] = i;
		}
	}

	int sz = 0, ugras = a[1][0], max_ert = 0, max_ind = 0;
	ki[0] = a[1][1];
	for(int i = 1; i <= m; i++) {
		if(i > ugras) {
			if(max_ert == 0) {
				cout << -1;
				return 0;
			}
			sz++;
			ki[sz] = max_ind;
			ugras = max_ert;
			max_ert = 0;
		}
		if(a[i][0] > max_ert) {
			max_ert = a[i][0];
			max_ind = a[i][1];
		}
	}
	cout << sz << '\n';
	for(int i = 0; i <= sz; i++) cout << ki[i] << ' ';


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base49/50
1Accepted0/01ms320 KiB
2Accepted0/09ms1080 KiB
3Wrong answer0/11ms508 KiB
4Accepted1/11ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/22ms320 KiB
8Accepted2/22ms380 KiB
9Accepted2/22ms320 KiB
10Accepted2/23ms320 KiB
11Accepted2/24ms572 KiB
12Accepted2/24ms732 KiB
13Accepted2/22ms568 KiB
14Accepted2/23ms568 KiB
15Accepted2/24ms804 KiB
16Accepted2/24ms648 KiB
17Accepted2/27ms1084 KiB
18Accepted2/28ms944 KiB
19Accepted2/28ms1080 KiB
20Accepted2/28ms1152 KiB
21Accepted2/29ms1196 KiB
22Accepted2/29ms1080 KiB
23Accepted2/28ms320 KiB
24Accepted2/28ms320 KiB
25Accepted2/28ms320 KiB
26Accepted2/28ms320 KiB
27Accepted2/28ms484 KiB
28Accepted2/28ms320 KiB