CF585D.Lizard Era: Beginning

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

在游戏《蜥蜴时代:开端》中,主角将与三位同伴——琳、梅莉安娜和沃里根一同冒险。整个游戏中共有 nn 个强制性任务。执行每个任务时,主角必须恰好选择两位同伴同行。

每位同伴对主角的好感度均为一个整数。初始时,每位同伴对主角的好感度均为中立值,即为 00。随着主角完成各项任务,他会采取一些行动,从而以正向或负向的方式改变本次任务所选同伴的好感度。

请确定主角在完成所有任务后,应如何为每个任务选择同伴,使得三位同伴的最终好感度完全相等。若存在多种方案可达成此目标,请选择其中最终好感度值最大的一种方案。

输入格式

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 107 in absolute value.

第一行包含一个正整数 nn(1≤n≤251 \leq n \leq 25)—— 表示重要任务的数量。

接下来的 nn 行描述了这些任务——第 ii 行包含三个整数 li, mi, wil_i,\, m_i,\, w_i,分别表示英雄接受第 ii 个任务后,琳恩(Lynn)、梅莉安娜(Meliana)和沃里根(Worrigan)三人对英雄的好感度变化值。输入中的所有数字均为整数,且其绝对值不超过 10710^7。

输出格式

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.

如果无解,在第一行输出“Impossible”。

否则,输出 nn 行,每行两个字符——在第 ii 行输出英雄为完成第 ii 个任务应携带的同伴姓名的首字母('L' 表示 Lynn,'M' 表示 Meliana,'W' 表示 Worrigan)。若存在多个解,可任意输出其中一个解,且每行的两个字母顺序不限。

输入输出样例

  • 输入#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

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

首页