問題一覧 > 通常問題

No.2745 String Swap Battle

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 35
作問者 : Nzt3 / テスター : ponjuice kenken714 cho435 tassei903
お気に入りにしたユーザー ProblemId : 10840 / 自分の提出
問題文最終更新日: 2024-04-26 12:59:18
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
CPCTF 2024 : PPC (順位表) の他の問題:

Problem Statement

There are $N$ players. Initially, person $i$ has a string $S_i$. Every player knows all of the strings held by everyone.

They play a game consisting of the following two stages.

Stage 1
  • Each player declares a positive integer of their choice
  • Let $K$ be the smallest of the declared positive integers
Stage 2
  • Each player $i$ performs the following operation exactly $K$ times
    • Choose two characters at different positions in the string $S_i$ they hold, and swap them

Among the strings finally produced, all people who hold the lexicographically smallest string win. Each winner gets $N+1-X$ points, where $X$ is the number of winners.

Find everyone's score when all players follow a strategy that maximizes their own score.

Constraints

  • $N \ge 2$
  • $2 \le |S_i| \le 10^5$
  • $\sum |S_i| \le 2 \times 10^5$
  • $S_i$ consists only of lowercase English letters

Input

The input is given from standard input in the following format.

$N$
$S_1$
$\vdots$
$S_N$

Output

Print $N$ lines. The $i$-th line should contain the score of player $i$ when all players follow a strategy that maximizes their own score.

Sample

Sample 1
Input
3
ac
re
wa
Output
0
0
3

When all players follow optimal strategies, only player $3$ wins. In this case, player $3$ gets $N+1-1=3$ points.

Sample 2
Input
4
abc
cba
bac
abc
Output
0
3
3
0

Sample 3
Input
5
apple
banana
cabbage
dragonfruit
egg
Output
0
0
5
0
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。