CF1861F.Four Suits

NOI/NOI+/CTSC

通过率:0%

时间限制:6.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

The game of Berland poker is played as follows. There are n+1n+1 people: nn players, numbered from 11 to nn, and the dealer. The dealer has a deck which contains cards of four different suits (the number of cards of each suit is not necessarily the same); the number of cards in the deck is divisible by nn. The dealer gives all cards to the players, so that every player receives the same number of cards, and the whole deck is used.

After the cards are dealt, every player chooses one of four suits (independently) and discards all cards from their hand which do not belong to their chosen suit. The winner of the game is the player with the maximum number of cards left in their hand. The number of points the winner receives is x−yx - y, where xx is the number of cards in the winner's hand, and yy is the maximum number of cards among all other players; everyone else receives 00 points. Note that it means that if there are multiple players with the maximum number of cards, everyone receives 00 points.

Since every player wants to maximize their odds to win, they will choose a suit with the maximum number of cards in their hand.

Monocarp is the dealer. He has already given some cards to the players; the ii-th player received ai,ja_{i,j} cards of suit jj. Note that the number of cards in players' hands don't have to be the same at this moment. Monocarp has b1,b2,b3,b4b_1, b_2, b_3, b_4 cards of suit 1,2,3,41, 2, 3, 4 respectively left in his deck. He has to give them to the players so that, after all cards are dealt, every player has the same number of cards.

For each player, calculate the maximum number of points they can receive among all ways to deal the remaining cards according to the rules of the game.

伯兰德扑克(Berland poker)游戏规则如下:共有 n+1n+1 人,其中 nn 名玩家(编号为 11 至 nn)和一名庄家。庄家拥有一副牌,牌面共分四种花色(每种花色的牌数不一定相等);整副牌的总张数能被 nn 整除。庄家将所有牌发给玩家,使得每位玩家获得相同数量的牌,且整副牌全部发完。

发牌结束后,每位玩家独立地从四种花色中选择一种,并弃掉手中所有不属于所选花色的牌。游戏的获胜者是手中剩余牌数最多的玩家。获胜者所得分数为 x−yx - y,其中 xx 是获胜者手中剩余的牌数,yy 是其余所有玩家中剩余牌数的最大值;其余所有玩家均得 00 分。注意:若存在多名玩家手中剩余牌数并列最多,则所有玩家均得 00 分。

由于每位玩家都希望最大化自己获胜的概率,因此他们总会选择自己手中数量最多的那种花色(若有多种花色数量相同且均为最大,则任选其一)。

Monocarp 是庄家。他已向各位玩家发出部分牌:第 ii 位玩家已收到花色 jj 的牌 ai,ja_{i,j} 张。注意:此时各位玩家手中的牌数未必相等。Monocarp 的牌堆中还剩下 b1,b2,b3,b4b_1, b_2, b_3, b_4 张花色分别为 1,2,3,41, 2, 3, 4 的牌。他必须将这些剩余的牌全部发给玩家,使得最终每位玩家手中的总牌数完全相等。

对每位玩家,请计算在所有符合游戏规则的剩余发牌方案中,该玩家所能获得的最高分数。

输入格式

The first line of the input contains one integer nn (2≤n≤5⋅1042 \le n \le 5 \cdot 10^4) — the number of players.

Then nn lines follow. The ii-th of them contains four integers ai,1,ai,2,ai,3,ai,4a_{i,1}, a_{i,2}, a_{i,3}, a_{i,4} (0≤ai,j≤1060 \le a_{i,j} \le 10^6), where ai,ja_{i,j} is the number of cards of the jj-th suit that the ii-th player currently has.

The last line contains 44 integers b1,b2,b3,b4b_1, b_2, b_3, b_4 (0≤bj≤1060 \le b_j \le 10^6), where bjb_j is the number of cards of the jj-th suit Monocarp has to deal yet.

Additional constraint on the input: it is possible to deal all of the remaining cards so that every player has the same number of cards.

输入的第一行包含一个整数 nn(2≤n≤5⋅1042 \le n \le 5 \cdot 10^4),表示玩家数量。

接下来是 nn 行。其中第 ii 行包含四个整数 ai,1,ai,2,ai,3,ai,4a_{i,1}, a_{i,2}, a_{i,3}, a_{i,4}(0≤ai,j≤1060 \le a_{i,j} \le 10^6),其中 ai,ja_{i,j} 表示第 ii 位玩家当前持有的第 jj 种花色的牌的数量。

最后一行包含四个整数 b1,b2,b3,b4b_1, b_2, b_3, b_4(0≤bj≤1060 \le b_j \le 10^6),其中 bjb_j 表示 Monocarp 尚需分发的第 jj 种花色的牌的数量。

输入的附加约束:可以将所有剩余的牌全部分发完毕,使得每位玩家最终持有的牌数相等。

输出格式

Print nn integers. The ii-th of them should be the maximum number of points the ii-th player can get among all possible ways to deal the remaining cards.

输出 nn 个整数。其中第 ii 个整数应为:在所有可能的剩余牌分配方式中,第 ii 个玩家所能获得的最大点数。

输入输出样例

  • 输入#1

    2
    3 1 1 1
    1 1 1 1
    2 2 0 0

    输出#1

    1 0
  • 输入#2

    4
    0 0 0 0
    0 0 0 1
    2 2 0 0
    0 1 0 0
    3 2 3 2

    输出#2

    1 1 1 1
  • 输入#3

    7
    2 1 0 1
    0 0 2 1
    4 4 1 2
    0 0 1 0
    1 1 0 1
    0 2 1 1
    0 2 0 0
    15 10 10 14

    输出#3

    5 6 1 7 5 5 7

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

首页