結果
問題 |
No.3001 ヘビ文字列
|
ユーザー |
![]() |
提出日時 | 2025-01-02 00:19:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 993 ms / 1,500 ms |
コード長 | 823 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 82,032 KB |
実行使用メモリ | 276,992 KB |
最終ジャッジ日時 | 2025-01-02 00:20:13 |
合計ジャッジ時間 | 46,293 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 83 |
ソースコード
import sys input = sys.stdin.readline S=input().strip() LEN=len(S) C=[0]*26 ANS=LEN ind=-1 for s in S: C[ord(s)-65]+=1 for i in range(26): x=C[i] if ANS>LEN-x: ANS=LEN-x ind=[chr(i+65)] 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=[0]*26 for j in range(t): C[ord(S[j*dis+i])-65]+=1 MAX=0 indm="" for j in range(26): if MAX<C[j]: MAX=C[j] indm=j score+=t-MAX L.append(chr(indm+65)) if score<ANS: ANS=score ind=L LANS=ind*(LEN//len(ind)) print("".join(LANS))