結果
問題 |
No.852 連続部分文字列
|
ユーザー |
![]() |
提出日時 | 2019-07-27 13:47:09 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 727 ms / 3,153 ms |
コード長 | 549 bytes |
コンパイル時間 | 3,677 ms |
コンパイル使用メモリ | 65,408 KB |
実行使用メモリ | 26,752 KB |
最終ジャッジ日時 | 2024-07-02 11:00:38 |
合計ジャッジ時間 | 11,509 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport] /home/judge/data/code/Main.nim(1, 31) Warning: imported and not used: 'algorithm' [UnusedImport]
ソースコード
import sequtils,strutils,math,algorithm var S = stdin.readline A : array['a'..'z', seq[int]] P : array['a'..'z', int] ans : float64 = 0.0 q = 0.0 for c in 'a'..'z': A[c] = @[] for i, c in S: A[c].add(i) for i in 0..S.high: var B = newSeq[int](0) for c in 'a'..'z': if A[c].high < P[c]: continue B.add(A[c][P[c]] - i) if c == S[i]: P[c] += 1 for j in 0..B.high: ans += (S.high - i + 1 - B[j]).float64 q += (S.high - i + 1).float64 echo ans / q