A10105 | Board Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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).
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).
输入格式
The first line of the input contains a single integer $n$ ( $1<=n<=100000$ ) — 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}<=10^{9}$ ) — the characteristics of the corresponding card.
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}<=10^{9}$ ) — the characteristics of the corresponding card.
输出格式
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$ .
If it is impossible to cast the $n$ -th spell, print $-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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted