結果
問題 |
No.3001 ヘビ文字列
|
ユーザー |
![]() |
提出日時 | 2025-01-02 00:12:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 792 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 82,660 KB |
実行使用メモリ | 258,352 KB |
最終ジャッジ日時 | 2025-01-02 00:14:13 |
合計ジャッジ時間 | 74,363 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 83 |
ソースコード
from collections import Counter import sys input = sys.stdin.readline S=input() LEN=len(S) C=Counter(S) ANS=LEN ind=-1 for a in C: x=C[a] if ANS>LEN-x: ANS=LEN-x ind=[a] x=LEN for t in range(2,LEN): if x%t==0: while x%t==0: x//=t dis=LEN//t score=0 L=[] for i in range(dis): C=Counter() for j in range(t): C[S[j*dis+i]]+=1 MAX=0 indm="" for c in C: if MAX<C[c]: MAX=C[c] indm=c score+=t-MAX L.append(indm) if score<ANS: ANS=score ind=L LANS=ind*(LEN//len(ind)) print("".join(LANS))