結果
| 問題 |
No.1192 半部分列
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:50:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 656 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 63,672 KB |
| 最終ジャッジ日時 | 2025-06-12 15:50:51 |
| 合計ジャッジ時間 | 2,632 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 15 |
ソースコード
def is_subsequence(s, t):
i = j = 0
len_s = len(s)
len_t = len(t)
while i < len_s and j < len_t:
if s[i] == t[j]:
i += 1
j += 1
return i == len_s
S = input().strip()
T = input().strip()
if not is_subsequence(S, T):
print(S)
else:
i = 0
n = len(S)
m = len(T)
prefix_matched = [False] * (n + 1)
prefix_matched[0] = True
j = 0
while i < n and j < m:
if S[i] == T[j]:
i += 1
prefix_matched[i] = True
j += 1
for k in range(1, n + 1):
if not prefix_matched[k]:
print(S[:k])
exit()
print(-1)
gew1fw