結果
問題 | No.2606 Mirror Relay |
ユーザー | 👑 amentorimaru |
提出日時 | 2023-11-09 00:04:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 243 ms / 2,000 ms |
コード長 | 1,952 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 82,548 KB |
実行使用メモリ | 197,600 KB |
最終ジャッジ日時 | 2024-09-27 17:43:33 |
合計ジャッジ時間 | 8,941 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
52,772 KB |
testcase_01 | AC | 34 ms
53,000 KB |
testcase_02 | AC | 35 ms
54,068 KB |
testcase_03 | AC | 36 ms
53,356 KB |
testcase_04 | AC | 46 ms
63,948 KB |
testcase_05 | AC | 46 ms
63,676 KB |
testcase_06 | AC | 44 ms
65,256 KB |
testcase_07 | AC | 44 ms
64,244 KB |
testcase_08 | AC | 46 ms
64,572 KB |
testcase_09 | AC | 47 ms
64,948 KB |
testcase_10 | AC | 45 ms
63,728 KB |
testcase_11 | AC | 46 ms
63,808 KB |
testcase_12 | AC | 44 ms
64,012 KB |
testcase_13 | AC | 44 ms
64,332 KB |
testcase_14 | AC | 35 ms
54,212 KB |
testcase_15 | AC | 33 ms
52,824 KB |
testcase_16 | AC | 34 ms
53,232 KB |
testcase_17 | AC | 35 ms
52,812 KB |
testcase_18 | AC | 35 ms
54,688 KB |
testcase_19 | AC | 60 ms
72,840 KB |
testcase_20 | AC | 59 ms
72,316 KB |
testcase_21 | AC | 58 ms
70,616 KB |
testcase_22 | AC | 68 ms
74,520 KB |
testcase_23 | AC | 62 ms
71,344 KB |
testcase_24 | AC | 59 ms
71,748 KB |
testcase_25 | AC | 55 ms
68,068 KB |
testcase_26 | AC | 51 ms
66,528 KB |
testcase_27 | AC | 60 ms
71,116 KB |
testcase_28 | AC | 62 ms
72,136 KB |
testcase_29 | AC | 50 ms
65,308 KB |
testcase_30 | AC | 46 ms
64,060 KB |
testcase_31 | AC | 48 ms
64,652 KB |
testcase_32 | AC | 48 ms
65,820 KB |
testcase_33 | AC | 47 ms
65,320 KB |
testcase_34 | AC | 48 ms
65,696 KB |
testcase_35 | AC | 46 ms
64,076 KB |
testcase_36 | AC | 51 ms
67,000 KB |
testcase_37 | AC | 51 ms
66,944 KB |
testcase_38 | AC | 49 ms
65,564 KB |
testcase_39 | AC | 116 ms
90,008 KB |
testcase_40 | AC | 122 ms
90,384 KB |
testcase_41 | AC | 122 ms
90,048 KB |
testcase_42 | AC | 120 ms
90,556 KB |
testcase_43 | AC | 116 ms
89,872 KB |
testcase_44 | AC | 119 ms
89,788 KB |
testcase_45 | AC | 115 ms
90,012 KB |
testcase_46 | AC | 118 ms
89,928 KB |
testcase_47 | AC | 116 ms
90,180 KB |
testcase_48 | AC | 120 ms
90,152 KB |
testcase_49 | AC | 168 ms
117,152 KB |
testcase_50 | AC | 172 ms
118,376 KB |
testcase_51 | AC | 171 ms
120,980 KB |
testcase_52 | AC | 144 ms
110,480 KB |
testcase_53 | AC | 153 ms
117,968 KB |
testcase_54 | AC | 173 ms
117,180 KB |
testcase_55 | AC | 227 ms
138,800 KB |
testcase_56 | AC | 189 ms
118,308 KB |
testcase_57 | AC | 163 ms
111,044 KB |
testcase_58 | AC | 181 ms
123,316 KB |
testcase_59 | AC | 121 ms
90,200 KB |
testcase_60 | AC | 126 ms
90,400 KB |
testcase_61 | AC | 119 ms
90,116 KB |
testcase_62 | AC | 127 ms
90,112 KB |
testcase_63 | AC | 133 ms
90,848 KB |
testcase_64 | AC | 118 ms
89,900 KB |
testcase_65 | AC | 125 ms
89,972 KB |
testcase_66 | AC | 118 ms
90,324 KB |
testcase_67 | AC | 119 ms
90,208 KB |
testcase_68 | AC | 125 ms
90,808 KB |
testcase_69 | AC | 243 ms
197,600 KB |
testcase_70 | AC | 35 ms
53,300 KB |
testcase_71 | AC | 33 ms
53,264 KB |
testcase_72 | AC | 34 ms
53,064 KB |
ソースコード
import sys input = sys.stdin.readline def read_values(): return tuple(map(int, input().split())) def read_list(): return list(map(int, input().split())) class PalindromicTree: def __init__(self): self.st=[] self.length=[-1,0] self.parent=[0,0] self.count=[0,0] self.link=[dict() for _ in range(2)] self.lastNodeIdx=0 def add(self,v): self.st.append(v) prevNodeIdx=self.lastNodeIdx nextNodeIdx=self.lastNodeIdx while True: head = self.length[nextNodeIdx] + 2 if head <= len(self.st) and self.st[-head]==self.st[-1]: break nextNodeIdx=self.parent[nextNodeIdx] nextLen=self.length[nextNodeIdx]+2 if v in self.link[nextNodeIdx].keys(): self.lastNodeIdx=self.link[nextNodeIdx][v] self.count[self.lastNodeIdx]+=1 return self.lastNodeIdx=len(self.length) self.length.append(nextLen) if self.length[-1]==1: self.parent.append(1) else: prevNodeIdx=self.parent[nextNodeIdx] while True: head = self.length[prevNodeIdx] + 2 if head <= len(self.st) and self.st[-head]==self.st[-1]: break prevNodeIdx=self.parent[prevNodeIdx] self.parent.append(self.link[prevNodeIdx][v]) self.count.append(1) self.link[nextNodeIdx][v]=self.lastNodeIdx self.link.append(dict()) def main(): s=input() pt = PalindromicTree() for i in range(len(s)-1,-1,-1): pt.add(s[i]) nodeCount = len(pt.length) count=pt.count[:] for i in range(nodeCount-1,1,-1): count[pt.parent[i]]+=count[i] score=[0]*nodeCount for i in range(2,nodeCount): score[i]=score[pt.parent[i]]+pt.length[i]*count[i] print(max(score)) if __name__ == "__main__": main()