結果
問題 | No.1192 半部分列 |
ユーザー | mkawa2 |
提出日時 | 2021-06-28 17:37:14 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 761 ms / 2,000 ms |
コード長 | 1,443 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 10,956 KB |
実行使用メモリ | 100,516 KB |
最終ジャッジ日時 | 2023-09-07 18:43:59 |
合計ジャッジ時間 | 6,891 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,088 KB |
testcase_01 | AC | 17 ms
8,176 KB |
testcase_02 | AC | 17 ms
8,100 KB |
testcase_03 | AC | 17 ms
8,092 KB |
testcase_04 | AC | 17 ms
8,028 KB |
testcase_05 | AC | 17 ms
8,184 KB |
testcase_06 | AC | 761 ms
100,516 KB |
testcase_07 | AC | 426 ms
75,632 KB |
testcase_08 | AC | 418 ms
75,640 KB |
testcase_09 | AC | 408 ms
72,996 KB |
testcase_10 | AC | 16 ms
8,024 KB |
testcase_11 | AC | 16 ms
8,080 KB |
testcase_12 | AC | 408 ms
75,668 KB |
testcase_13 | AC | 186 ms
36,816 KB |
testcase_14 | AC | 252 ms
50,892 KB |
testcase_15 | AC | 235 ms
48,164 KB |
testcase_16 | AC | 163 ms
37,616 KB |
testcase_17 | AC | 240 ms
49,460 KB |
testcase_18 | AC | 17 ms
8,292 KB |
testcase_19 | AC | 73 ms
20,036 KB |
testcase_20 | AC | 17 ms
8,080 KB |
testcase_21 | AC | 180 ms
39,836 KB |
testcase_22 | AC | 20 ms
8,608 KB |
testcase_23 | AC | 435 ms
75,336 KB |
testcase_24 | AC | 66 ms
19,304 KB |
testcase_25 | AC | 142 ms
34,576 KB |
testcase_26 | AC | 135 ms
35,068 KB |
testcase_27 | AC | 199 ms
40,256 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 md = 998244353 # md = 10**9+7 s = SI() t = SI() m, n = len(s), len(t) # sub[i]=j...s[i:]はt[j:]の部分文字列 sub = [-1]*m j = n-1 for i in range(m-1, -1, -1): while j >= 0 and s[i] != t[j]: j -= 1 sub[i] = j j -= 1 # print(sub) def maketo(s): res = [] now = [-1]*26 for i in range(len(s)-1, -1, -1): res.append(now[:]) c = ord(s[i])-97 now[c] = i res.append(now[:]) return res[::-1] tos = maketo(s) tot = maketo(t) # print(tos, tot) def dfs(i=0, j=0): if i == m: return "" if j <= sub[i]: return "" for c in range(26): if tos[i][c] == -1: continue if tot[j][c] == -1: return chr(c+97) ret = dfs(tos[i][c]+1, tot[j][c]+1) if ret == "": continue return chr(c+97)+ret return "" ans = dfs() if ans == "": print(-1) else: print(ans)