結果
問題 | 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 sysinput = sys.stdin.readlineS=input().strip()LEN=len(S)C=[0]*26ANS=LENind=-1for s in S:C[ord(s)-65]+=1for i in range(26):x=C[i]if ANS>LEN-x:ANS=LEN-xind=[chr(i+65)]x=LENfor t in range(2,LEN):if x%t==0:while x%t==0:x//=tdis=LEN//tscore=0L=[]for i in range(dis):C=[0]*26for j in range(t):C[ord(S[j*dis+i])-65]+=1MAX=0indm=""for j in range(26):if MAX<C[j]:MAX=C[j]indm=jscore+=t-MAXL.append(chr(indm+65))if score<ANS:ANS=scoreind=LLANS=ind*(LEN//len(ind))print("".join(LANS))