CF605D.Board Game

省选/NOI-

通过率:0%

时间限制:2.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are playing a board card game. In this game the player has two characteristics, x and y — the white magic skill and the black magic skill, respectively. There are n spell cards lying on the table, each of them has four characteristics, a__i, b__i, c__i and d__i. In one move a player can pick one of the cards and cast the spell written on it, but only if first two of it's characteristics meet the requirement a__i ≤ x and b__i ≤ y, i.e. if the player has enough magic skill to cast this spell. However, after casting the spell the characteristics of a player change and become equal to x = c__i and y = d__i.

At the beginning of the game both characteristics of a player are equal to zero. The goal of the game is to cast the n-th spell. Your task is to make it in as few moves as possible. You are allowed to use spell in any order and any number of times (for example, you may not use some spells at all).

你正在玩一款桌面卡牌游戏。在该游戏中,玩家具有两项属性:xx 和 yy,分别代表白魔法技能与黑魔法技能。桌面上共有 nn 张法术卡,每张卡具有四项属性:aia_i、bib_i、cic_i 和 did_i。在一次操作中,玩家可选择其中一张卡并施放其上记载的法术,但前提是该卡的前两项属性满足要求 ai≤xa_i \le x 且 bi≤yb_i \le y,即玩家当前具备足够的魔法技能来施放该法术。然而,施放法术后,玩家的属性将立即更新为 x=cix = c_i、y=diy = d_i。

游戏开始时,玩家的两项属性均为零。游戏目标是施放第 nn 张法术卡(即编号为 nn 的卡)。你的任务是以最少的操作次数达成该目标。你可以按任意顺序、任意次数使用法术卡(例如,某些法术卡可以完全不使用)。

输入格式

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of cards on the table.

Each of the next n lines contains four integers a__i, b__i, c__i, d__i (0 ≤ a__i, b__i, c__i, d__i ≤ 109) — the characteristics of the corresponding card.

输入的第一行包含一个整数 nn(1 ≤ n ≤ 100 0001 ≤ n ≤ 100\,000)—— 表上卡片的数量。

接下来的 nn 行中,每行包含四个整数 aia_i、bib_i、cic_i、did_i(0 ≤ ai, bi, ci, di ≤ 1090 ≤ a_i,\,b_i,\,c_i,\,d_i ≤ 10^9)—— 对应卡片的属性。

输出格式

In the first line print a single integer k — the minimum number of moves needed to cast the n-th spell and in the second line print k numbers — the indices of the cards in the order in which you should cast them. In case there are multiple possible solutions, print any of them.

If it is impossible to cast the n-th spell, print  - 1.

第一行输出一个整数 kk —— 施放第 nn 个法术所需的最少操作次数;第二行输出 kk 个数字 —— 按照施放顺序排列的卡牌索引。若存在多种可能的解,输出任意一种即可。

若无法施放第 nn 个法术,则输出 −1-1。

输入输出样例

  • 输入#1

    4
    0 0 3 4
    2 2 5 3
    4 1 1 7
    5 3 8 8

    输出#1

    3
    1 2 4
  • 输入#2

    2
    0 0 4 6
    5 1 1000000000 1000000000

    输出#2

    -1

输入解题思路,AI测评打分。不知道怎么写?

首页