結果
| 問題 | No.3626 Not a Prefix |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-08-14 23:24:30 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,147 bytes |
| 記録 | |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 126,012 KB |
| 最終ジャッジ日時 | 2026-08-14 23:24:38 |
| 合計ジャッジ時間 | 8,117 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 42 WA * 3 |
ソースコード
def main():
n, m = list(map(int, input().split()))
S = [input() for _ in range(n)]
i = 0
j = 0
Ans = []
while m and i < 26:
#print(Ans, m, S)
c = chr(97+i)
cnt = 0
cnt0 = 0
for s in S:
if s[j] == c and len(s)-1 == j:
cnt += 1
if s[j] != c:
cnt0 += 1
if m <= cnt0:
return "".join(Ans) + c
if len(S)-cnt < m:
T = []
for s in S:
if s[j] != c:
T.append(s)
else:
m -= 1
i += 1
if m <= 0 and i < 26:
return "".join(Ans) + chr(97+i)
S = T
else:
Ans.append(c)
T = []
for s in S:
if s[j] == c and len(s)-1 == j:
pass
elif s[j] != c:
m -= 1
else:
T.append(s)
S = T
i = 0
j += 1
return ""
ans = main()
if ans == "":
print("No")
else:
print("Yes")
print(ans)
kidodesu