2692021-05-17 11:55:27kidesoÜgyeletcpp11Wrong answer 4/4026ms2892 KiB
#include <iostream>
#include <vector>
#include <algorithm>

#define par pair <int,int>
#define kezd first
#define veg second
using namespace std;


struct adat
{
	par id;
	int s, v;
};

vector <adat> x;
vector <int> megold;
int N, M, a, b;

bool r(const adat& a, const adat& b)
{
	if (a.id.kezd != b.id.kezd) return a.id.kezd < b.id.kezd;
	return a.id.veg < b.id.veg;
}

int main()
{
	cin >> N >> M;
	x.resize(M + 1);
	for (int i = 1; i <= M; ++i)
	{
		cin >> a >> b;
		x[i] = { {a,b},i,0 };
	}

	sort(x.begin(), x.end(), r);

	a = b = 1;
	int i = 1;
	while (a < N || b < N)
	{
		if (a < b)
		{
			i = 1;
			while (i <= M && x[i].id.kezd <= a) ++i;
			--i;
			while (x[i].v != 0) --i;
			a = x[i].id.veg + 1;
			x[i].v = 1;
			megold.push_back(x[i].s);
		}
		else
		{
			i = 1;
			while (i <= M && x[i].id.kezd <= b) ++i;
			--i;
			while (x[i].v != 0) --i;
			x[i].v = 1;
			b = x[i].id.veg + 1;
			megold.push_back(x[i].s);
		}
	}

	cout << megold.size() << '\n';
	for (auto e : megold) cout << e << ' ';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/40
1Accepted0/02ms1808 KiB
2Wrong answer0/04ms2048 KiB
3Wrong answer0/21ms1952 KiB
4Wrong answer0/21ms1956 KiB
5Partially correct1/21ms1960 KiB
6Wrong answer0/21ms1964 KiB
7Wrong answer0/21ms1968 KiB
8Wrong answer0/21ms1988 KiB
9Wrong answer0/22ms2000 KiB
10Wrong answer0/21ms2016 KiB
11Wrong answer0/21ms2020 KiB
12Runtime error0/18ms2400 KiB
13Wrong answer0/22ms2060 KiB
14Wrong answer0/23ms2104 KiB
15Wrong answer0/24ms2156 KiB
16Accepted3/316ms2592 KiB
17Wrong answer0/317ms2520 KiB
18Wrong answer0/325ms2656 KiB
19Wrong answer0/326ms2772 KiB
20Wrong answer0/325ms2892 KiB