結果
問題 | No.765 ukuku 2 |
ユーザー | mkawa2 |
提出日時 | 2022-02-08 16:51:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,965 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 86,664 KB |
実行使用メモリ | 168,860 KB |
最終ジャッジ日時 | 2023-09-05 16:35:03 |
合計ジャッジ時間 | 24,695 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 92 ms
168,860 KB |
testcase_01 | AC | 93 ms
71,620 KB |
testcase_02 | AC | 97 ms
71,788 KB |
testcase_03 | AC | 92 ms
71,764 KB |
testcase_04 | AC | 93 ms
71,616 KB |
testcase_05 | AC | 92 ms
71,448 KB |
testcase_06 | AC | 94 ms
71,616 KB |
testcase_07 | AC | 95 ms
71,640 KB |
testcase_08 | AC | 93 ms
71,856 KB |
testcase_09 | AC | 93 ms
71,900 KB |
testcase_10 | AC | 95 ms
71,616 KB |
testcase_11 | AC | 98 ms
71,856 KB |
testcase_12 | WA | - |
testcase_13 | AC | 98 ms
71,920 KB |
testcase_14 | AC | 97 ms
71,768 KB |
testcase_15 | AC | 98 ms
71,956 KB |
testcase_16 | AC | 98 ms
71,908 KB |
testcase_17 | AC | 98 ms
72,032 KB |
testcase_18 | AC | 94 ms
72,032 KB |
testcase_19 | AC | 94 ms
71,772 KB |
testcase_20 | AC | 95 ms
71,952 KB |
testcase_21 | AC | 93 ms
72,040 KB |
testcase_22 | AC | 92 ms
71,852 KB |
testcase_23 | AC | 93 ms
71,780 KB |
testcase_24 | AC | 95 ms
71,824 KB |
testcase_25 | AC | 93 ms
71,876 KB |
testcase_26 | AC | 103 ms
77,032 KB |
testcase_27 | AC | 107 ms
76,956 KB |
testcase_28 | AC | 107 ms
76,864 KB |
testcase_29 | AC | 104 ms
76,888 KB |
testcase_30 | AC | 2,824 ms
91,472 KB |
testcase_31 | AC | 2,733 ms
92,268 KB |
testcase_32 | AC | 2,260 ms
87,896 KB |
testcase_33 | AC | 534 ms
95,132 KB |
testcase_34 | AC | 533 ms
96,640 KB |
testcase_35 | AC | 1,804 ms
96,628 KB |
testcase_36 | AC | 1,983 ms
97,060 KB |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
ソースコード
def solve(): import sys def SI(): return sys.stdin.readline().rstrip() from random import randrange s = SI() n = len(s) BASE = randrange(128, 256) MOD = (1 << 61)-1 h = [0] pw = [1] for c in s: h += [h[-1]*BASE%MOD+ord(c)] pw += [pw[-1]*BASE%MOD] rh = [0] for c in s[::-1]: rh += [rh[-1]*BASE%MOD+ord(c)] def hash(h, l, r): return (h[r]-h[l]*pw[r-l]%MOD)%MOD def binary_search(l, r, i, j): if l > r: return -1 r += 1 while l+1 < r: m = (l+r)//2 if hash(h, i-m, i) == hash(rh, n-(j+m), n-j): l = m else: r = m return l ans = 1 for i in range(1, n): r = min(i, n-i) if r*2 <= ans: continue d = binary_search(0, r, i, i) if d*2 == n: print(n-1) exit() # delete left ni, nj = i-d-1, i+d r = min(ni, n-nj) if ni >= 0 and (d+r)*2 > ans: e = binary_search(ans//2-d, r, ni, nj) if e != -1: ans = max(ans, (d+e)*2) # delete right ni, nj = i-d, i+d+1 r = min(ni, n-nj) if nj <= n and (d+r)*2 > ans: e = binary_search(ans//2-d, r, ni, nj) if e != -1: ans = max(ans, (d+e)*2) for i in range(n-1): r = min(i, n-i-1) if r*2+1 <= ans: continue d = binary_search(0, r, i, i+1) if d*2+1 == n: print(n-1) exit() # delete left ni, nj = i-d-1, i+1+d r = min(ni, n-nj) if ni >= 0 and (d+r)*2+1 > ans: e = binary_search((ans-1)//2-d, r, ni, nj) if e != -1: ans = max(ans, (d+e)*2+1) # delete right ni, nj = i-d, i+d+2 r = min(ni, n-nj) if nj <= n and (d+r)*2+1 > ans: e = binary_search((ans-1)//2-d, r, ni, nj) if e != -1: ans = max(ans, (d+e)*2+1) print(ans) solve()