結果
| 問題 |
No.2715 Unique Chimatagram
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-10 06:55:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,401 bytes |
| コンパイル時間 | 415 ms |
| コンパイル使用メモリ | 82,904 KB |
| 実行使用メモリ | 81,324 KB |
| 最終ジャッジ日時 | 2025-06-10 06:55:56 |
| 合計ジャッジ時間 | 8,694 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 2 |
ソースコード
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush, nlargest, nsmallest
from bisect import bisect_left, bisect, bisect_right
from copy import deepcopy
from time import perf_counter
import sys
from typing import Any, List, Callable
def debug(*args, sep=" ", end="\n") -> None:
print(*args, sep=sep, end=end, file=sys.stderr)
def main():
global inf, MOD
input = sys.stdin.read().split()
ptr = 0
inf = float("inf")
MOD = 998244353
N = int(input[ptr]); ptr += 1
S = input[ptr:ptr + N]; ptr += N
C = [Counter(s) for s in S]
alph = "qwertyuiopasdfghjklzxcvbnm"
M = 26
assert len(alph) == M
for i in range(N):
d = C[i]
D = [True] * M
for j in range(N):
if i == j or len(S[i]) != len(S[j]):
continue
dd = C[j]
if any(abs(d[c] - dd[c]) > 1 for c in alph):
continue
diff = sum(d[c] != dd[c] for c in alph)
if diff > 2:
continue
elif diff == 0:
break
for k, c in enumerate(alph):
if d[c] != dd[c]:
D[k] = False
else:
if any(D):
c = alph[D.index(True)]
print(S[i] + c)
sys.exit()
print(-1)
if __name__ == "__main__":
main()