結果
問題 | No.2606 Mirror Relay |
ユーザー | 👑 amentorimaru |
提出日時 | 2023-11-02 00:51:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,256 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 123,600 KB |
最終ジャッジ日時 | 2024-01-02 13:43:24 |
合計ジャッジ時間 | 10,359 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,460 KB |
testcase_01 | AC | 37 ms
53,460 KB |
testcase_02 | AC | 36 ms
53,460 KB |
testcase_03 | AC | 38 ms
53,460 KB |
testcase_04 | AC | 52 ms
64,216 KB |
testcase_05 | AC | 50 ms
64,212 KB |
testcase_06 | AC | 49 ms
64,212 KB |
testcase_07 | AC | 49 ms
64,212 KB |
testcase_08 | AC | 49 ms
64,216 KB |
testcase_09 | AC | 49 ms
64,212 KB |
testcase_10 | AC | 50 ms
64,212 KB |
testcase_11 | AC | 51 ms
64,228 KB |
testcase_12 | AC | 55 ms
66,440 KB |
testcase_13 | AC | 50 ms
64,216 KB |
testcase_14 | AC | 38 ms
53,460 KB |
testcase_15 | AC | 37 ms
53,460 KB |
testcase_16 | AC | 38 ms
53,460 KB |
testcase_17 | AC | 37 ms
53,460 KB |
testcase_18 | AC | 44 ms
59,208 KB |
testcase_19 | AC | 74 ms
73,712 KB |
testcase_20 | AC | 70 ms
73,308 KB |
testcase_21 | AC | 71 ms
73,316 KB |
testcase_22 | AC | 72 ms
73,332 KB |
testcase_23 | AC | 71 ms
73,312 KB |
testcase_24 | AC | 73 ms
73,464 KB |
testcase_25 | AC | 67 ms
71,112 KB |
testcase_26 | AC | 58 ms
68,504 KB |
testcase_27 | AC | 69 ms
73,332 KB |
testcase_28 | AC | 75 ms
74,224 KB |
testcase_29 | AC | 54 ms
66,292 KB |
testcase_30 | AC | 51 ms
66,288 KB |
testcase_31 | AC | 55 ms
66,316 KB |
testcase_32 | AC | 56 ms
66,288 KB |
testcase_33 | AC | 58 ms
68,504 KB |
testcase_34 | AC | 50 ms
64,224 KB |
testcase_35 | AC | 54 ms
66,316 KB |
testcase_36 | AC | 55 ms
66,432 KB |
testcase_37 | AC | 52 ms
66,288 KB |
testcase_38 | AC | 52 ms
66,288 KB |
testcase_39 | AC | 143 ms
89,756 KB |
testcase_40 | AC | 140 ms
89,628 KB |
testcase_41 | AC | 143 ms
89,744 KB |
testcase_42 | AC | 145 ms
89,612 KB |
testcase_43 | AC | 145 ms
89,604 KB |
testcase_44 | AC | 148 ms
89,596 KB |
testcase_45 | AC | 145 ms
90,040 KB |
testcase_46 | AC | 145 ms
89,732 KB |
testcase_47 | AC | 141 ms
88,324 KB |
testcase_48 | AC | 141 ms
90,040 KB |
testcase_49 | AC | 1,868 ms
115,960 KB |
testcase_50 | TLE | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
testcase_66 | -- | - |
testcase_67 | -- | - |
testcase_68 | -- | - |
testcase_69 | -- | - |
testcase_70 | -- | - |
testcase_71 | -- | - |
testcase_72 | -- | - |
ソースコード
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): pt.add(s[i]) nodeCount = len(pt.length) count=[0]*nodeCount for i in range(nodeCount): node=i while node>1: count[node]+=pt.count[i] node=pt.parent[node] score=[-1]*nodeCount score[0]=0 score[1]=0 for i in range(nodeCount): if score[i]!=-1: continue stk=[i] while score[stk[-1]]==-1: stk.append(pt.parent[stk[-1]]) tmp=score[stk[-1]] stk.pop() for v in stk[::-1]: tmp+=pt.length[v]*count[v] score[v]=tmp print(max(score)) if __name__ == "__main__": main()