A12149 | Last chance
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
It is the year 2969. 1000 years have passed from the moon landing. Meanwhile, the humanity colonized the Hyperspace™ and lived in harmony.
Until we realized that we were not alone.
Not too far away from the Earth, the massive fleet of aliens' spaceships is preparing to attack the Earth. For the first time in a while, the humanity is in real danger. Crisis and panic are everywhere. The scientists from all around the solar system have met and discussed the possible solutions. However, no progress has been made.
The Earth's last hope is YOU!
Fortunately, the Earth is equipped with very powerful defense systems made by MDCS. There are $N$ aliens' spaceships which form the line. The defense system consists of three types of weapons:
- SQL rockets – every SQL rocket can destroy at most one spaceship in the given set.
- Cognition beams – every Cognition beam has an interval $[l,r]$ and can destroy at most one spaceship in that interval.
- OMG bazooka – every OMG bazooka has three possible targets, however, each bazooka can destroy either zero or exactly two spaceships. In addition, due to the smart targeting system, the sets of the three possible targets of any two different OMG bazookas are disjoint (that means that every ship is targeted with at most one OMG bazooka).
Your task is to make a plan of the attack which will destroy the largest possible number of spaceships. Every destroyed spaceship should be destroyed with exactly one weapon.
Until we realized that we were not alone.
Not too far away from the Earth, the massive fleet of aliens' spaceships is preparing to attack the Earth. For the first time in a while, the humanity is in real danger. Crisis and panic are everywhere. The scientists from all around the solar system have met and discussed the possible solutions. However, no progress has been made.
The Earth's last hope is YOU!
Fortunately, the Earth is equipped with very powerful defense systems made by MDCS. There are $N$ aliens' spaceships which form the line. The defense system consists of three types of weapons:
- SQL rockets – every SQL rocket can destroy at most one spaceship in the given set.
- Cognition beams – every Cognition beam has an interval $[l,r]$ and can destroy at most one spaceship in that interval.
- OMG bazooka – every OMG bazooka has three possible targets, however, each bazooka can destroy either zero or exactly two spaceships. In addition, due to the smart targeting system, the sets of the three possible targets of any two different OMG bazookas are disjoint (that means that every ship is targeted with at most one OMG bazooka).
Your task is to make a plan of the attack which will destroy the largest possible number of spaceships. Every destroyed spaceship should be destroyed with exactly one weapon.
输入格式
The first line contains two integers: the number of your weapons $N$ $(1\leq N\leq 5000)$ and the number of spaceships $M$ $(1\leq M\leq 5000)$ .
In the next $N$ lines, each line starts with one integer that represents type (either 0, 1 or 2). If the type is 0, then the weapon is SQL rocket, the rest of the line contains strictly positive number $K$ $(\sum{K} \leq 100 000)$ and array $k_i$ $(1\leq k_i\leq M)$ of $K$ integers. If the type is 1, then the weapon is Cognition beam, the rest of the line contains integers $l$ and $r$ $(1\leq l\leq r\leq M)$ . If the type is 2 then the weapon is OMG bazooka, the rest of the line contains distinct numbers $a$ , $b$ and $c$ $ (1 \leq a,b,c \leq M)$ .
In the next $N$ lines, each line starts with one integer that represents type (either 0, 1 or 2). If the type is 0, then the weapon is SQL rocket, the rest of the line contains strictly positive number $K$ $(\sum{K} \leq 100 000)$ and array $k_i$ $(1\leq k_i\leq M)$ of $K$ integers. If the type is 1, then the weapon is Cognition beam, the rest of the line contains integers $l$ and $r$ $(1\leq l\leq r\leq M)$ . If the type is 2 then the weapon is OMG bazooka, the rest of the line contains distinct numbers $a$ , $b$ and $c$ $ (1 \leq a,b,c \leq M)$ .
输出格式
The first line should contain the maximum number of destroyed spaceships — $X$ .
In the next $X$ lines, every line should contain two numbers $A$ and $B$ , where $A$ is an index of the weapon and $B$ is an index of the spaceship which was destroyed by the weapon $A$ .
In the next $X$ lines, every line should contain two numbers $A$ and $B$ , where $A$ is an index of the weapon and $B$ is an index of the spaceship which was destroyed by the weapon $A$ .
输入输出样例
输入 #1
3 5 0 1 4 2 5 4 1 1 1 4
输出 #1
4 2 1 3 2 1 4 2 5
SQL rocket can destroy only 4th spaceship. OMG Bazooka can destroy two of 1st, 4th or 5th spaceship, and Cognition beam can destroy any spaceship from the interval $[1,4]$ . The maximum number of destroyed spaceship is 4, and one possible plan is that SQL rocket should destroy 4th spaceship, OMG bazooka should destroy 1st and 5th spaceship and Cognition beam should destroy 2nd spaceship.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted