問題一覧 > 通常問題

No.2715 Unique Chimatagram

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 155
作問者 : ecottea / テスター : 👑 p-adic 👑 hamamu
お気に入りにしたユーザー ProblemId : 10644 / 自分の提出
問題文最終更新日: 2024-02-08 21:47:57
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. Back to the original
yukicoder contest 426 (順位表) の他の問題:

Problem Statement

For strings $S, T$ consisting of lowercase English letters, $T$ is called a chimatagram of $S$ if $T$ can be obtained by performing the following operations on $S$ in order:

  1. Append $1$ lowercase English letter of your choice to the end of $S$.
  2. Rearrange the characters of $S$ in any order of your choice.

You are given strings $S_1, \ldots, S_N$ consisting of lowercase English letters. Determine whether there exists a string $T$ of lowercase English letters satisfying the following condition, and if it exists, print $1$ such $T$:

  • (Condition) There exists exactly one $1 \leq i \leq N$ such that $T$ is a chimatagram of $S_i$.

Constraints

  • $1 \leq N \leq 10^3$
  • $N$ is an integer
  • $S_i$ is a string of length between $1$ and $10$, inclusive, consisting only of lowercase English letters

Input

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

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

Output

If there exists a string $T$ of lowercase English letters satisfying the condition, print $1$ such $T$. If it does not exist, print -1.
Print a newline at the end.

Sample

Sample 1
Input
3
rock
scissors
paper
Output
appear

appear can be made by appending a to paper and rearranging, so it is a chimatagram of paper. On the other hand, it can be proved that appear is not a chimatagram of rock or scissors.

Sample 2
Input
2
file
life
Output
-1

For example, flier is a chimatagram of file, but it is also a chimatagram of life, so it does not satisfy the condition.

Sample 3
Input
5
one
plus
one
equals
two
Output
pulse

The strings $S_i$ may contain identical strings.

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