結果
問題 |
No.1192 半部分列
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:00:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 656 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 63,104 KB |
最終ジャッジ日時 | 2025-06-12 21:03:43 |
合計ジャッジ時間 | 2,614 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)