A9984 | Lizard Era: Beginning
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has $n$ mandatory quests. To perform each of them, you need to take exactly two companions.
The attitude of each of the companions to the hero is an integer. Initially, the attitude of each of them to the hero of neutral and equal to 0. As the hero completes quests, he makes actions that change the attitude of the companions, whom he took to perform this task, in positive or negative direction.
Tell us what companions the hero needs to choose to make their attitude equal after completing all the quests. If this can be done in several ways, choose the one in which the value of resulting attitude is greatest possible.
The attitude of each of the companions to the hero is an integer. Initially, the attitude of each of them to the hero of neutral and equal to 0. As the hero completes quests, he makes actions that change the attitude of the companions, whom he took to perform this task, in positive or negative direction.
Tell us what companions the hero needs to choose to make their attitude equal after completing all the quests. If this can be done in several ways, choose the one in which the value of resulting attitude is greatest possible.
输入格式
The first line contains positive integer $n$ ( $1<=n<=25$ ) — the number of important tasks.
Next $n$ lines contain the descriptions of the tasks — the $i$ -th line contains three integers $l_{i},m_{i},w_{i}$ — the values by which the attitude of Lynn, Meliana and Worrigan respectively will change towards the hero if the hero takes them on the $i$ -th task. All the numbers in the input are integers and do not exceed $10^{7}$ in absolute value.
Next $n$ lines contain the descriptions of the tasks — the $i$ -th line contains three integers $l_{i},m_{i},w_{i}$ — the values by which the attitude of Lynn, Meliana and Worrigan respectively will change towards the hero if the hero takes them on the $i$ -th task. All the numbers in the input are integers and do not exceed $10^{7}$ in absolute value.
输出格式
If there is no solution, print in the first line "Impossible".
Otherwise, print $n$ lines, two characters is each line — in the $i$ -th line print the first letters of the companions' names that hero should take to complete the $i$ -th task ('L' for Lynn, 'M' for Meliana, 'W' for Worrigan). Print the letters in any order, if there are multiple solutions, print any of them.
Otherwise, print $n$ lines, two characters is each line — in the $i$ -th line print the first letters of the companions' names that hero should take to complete the $i$ -th task ('L' for Lynn, 'M' for Meliana, 'W' for Worrigan). Print the letters in any order, if there are multiple solutions, print any of them.
输入输出样例
输入 #1
3 1 0 0 0 1 0 0 0 1
输出 #1
LM MW MW
输入 #2
7 0 8 9 5 9 -2 6 -8 -7 9 4 5 -4 -9 9 -4 5 2 -6 8 -7
输出 #2
LM MW LM LW MW LM LW
输入 #3
2 1 0 0 1 1 0
输出 #3
Impossible
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted