39332023-03-05 21:48:29SleepyOverlordA lehető legkevesebb átszállás (50 pont)cpp17Accepted 50/508ms4228 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

#define IN_FILE "a.in"
#define OUT_FILE "a.out"

template <typename T>
void PR(T var1)
{
	cout << var1 <<endl;
}
template <typename T, typename... Types>
void PR(T var1, Types... var2)
{
	cout << var1;
	PR(var2...);
}

int n, m;
VPII a;
VI b;

int main()
{
	cin >> m >> n;
	a.RS(m + 1);
	FOR(i, 1, m) cin >> a[i].X >> a[i].Y;

	int i = 1, covered = 1;
	while (covered < n)
	{
		int best = -1;
		while (i <= m && a[i].X <= covered)
		{
			if (best == -1 || a[best].Y < a[i].Y)
			{
				best = i;
			}
			++i;
		}
		if (best == -1)
		{
			PR(-1);
			return 0;
		}
		covered = a[best].Y;
		b.PB(best);
	}

	PR(b.SZ - 1);
	for (int i : b) cout << i << " ";

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/08ms2332 KiB
3Accepted1/12ms2412 KiB
4Accepted1/13ms2620 KiB
5Accepted2/22ms2628 KiB
6Accepted2/22ms2820 KiB
7Accepted2/23ms3040 KiB
8Accepted2/23ms3128 KiB
9Accepted2/24ms3160 KiB
10Accepted2/24ms3368 KiB
11Accepted2/24ms3472 KiB
12Accepted2/26ms3620 KiB
13Accepted2/23ms3468 KiB
14Accepted2/24ms3692 KiB
15Accepted2/24ms3672 KiB
16Accepted2/26ms3576 KiB
17Accepted2/27ms3864 KiB
18Accepted2/28ms3616 KiB
19Accepted2/28ms3672 KiB
20Accepted2/28ms3924 KiB
21Accepted2/28ms3888 KiB
22Accepted2/28ms4136 KiB
23Accepted2/28ms4012 KiB
24Accepted2/28ms3904 KiB
25Accepted2/28ms3904 KiB
26Accepted2/28ms3908 KiB
27Accepted2/28ms3948 KiB
28Accepted2/28ms4228 KiB