結果
| 問題 |
No.1192 半部分列
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 01:02:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,030 bytes |
| コンパイル時間 | 495 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 76,596 KB |
| 最終ジャッジ日時 | 2025-04-16 01:05:07 |
| 合計ジャッジ時間 | 2,595 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 8 |
ソースコード
from collections import Counter
def is_subsequence(s, t):
it = iter(t)
for c in s:
found = False
while True:
try:
curr = next(it)
if curr == c:
found = True
break
except StopIteration:
break
if not found:
return False
return True
s = input().strip()
t = input().strip()
# Step 1: Check for any character in S not present in T
t_chars = set(t)
missing_chars = []
for c in s:
if c not in t_chars:
missing_chars.append(c)
if missing_chars:
print(min(missing_chars))
exit()
# Step 2: Check for characters where count in S exceeds count in T
count_s = Counter(s)
count_t = Counter(t)
for c in 'abcdefghijklmnopqrstuvwxyz':
if count_s.get(c, 0) > count_t.get(c, 0):
required = count_t[c] + 1
print(c * required)
exit()
# Step 3: Check if S is a subsequence of T
if not is_subsequence(s, t):
print(s)
else:
print(-1)
lam6er