結果
問題 | No.852 連続部分文字列 |
ユーザー | kuuso1 |
提出日時 | 2019-07-26 23:23:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,824 bytes |
コンパイル時間 | 3,972 ms |
コンパイル使用メモリ | 107,596 KB |
実行使用メモリ | 28,824 KB |
最終ジャッジ日時 | 2023-09-15 04:40:56 |
合計ジャッジ時間 | 12,452 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 62 ms
28,824 KB |
testcase_01 | AC | 61 ms
24,596 KB |
testcase_02 | AC | 61 ms
22,384 KB |
testcase_03 | AC | 62 ms
22,508 KB |
testcase_04 | AC | 61 ms
22,484 KB |
testcase_05 | AC | 61 ms
22,404 KB |
testcase_06 | AC | 62 ms
24,412 KB |
testcase_07 | AC | 62 ms
24,492 KB |
testcase_08 | AC | 62 ms
22,544 KB |
testcase_09 | AC | 61 ms
24,448 KB |
testcase_10 | AC | 61 ms
22,392 KB |
testcase_11 | AC | 62 ms
22,488 KB |
testcase_12 | AC | 62 ms
24,640 KB |
testcase_13 | AC | 147 ms
24,516 KB |
testcase_14 | AC | 98 ms
22,680 KB |
testcase_15 | AC | 203 ms
22,440 KB |
testcase_16 | AC | 146 ms
22,472 KB |
testcase_17 | AC | 181 ms
20,624 KB |
testcase_18 | AC | 214 ms
22,516 KB |
testcase_19 | AC | 72 ms
22,352 KB |
testcase_20 | AC | 129 ms
24,496 KB |
testcase_21 | AC | 215 ms
22,428 KB |
testcase_22 | AC | 110 ms
22,580 KB |
testcase_23 | AC | 167 ms
22,520 KB |
testcase_24 | AC | 124 ms
22,456 KB |
testcase_25 | AC | 163 ms
22,404 KB |
testcase_26 | AC | 213 ms
22,436 KB |
testcase_27 | AC | 150 ms
22,428 KB |
testcase_28 | AC | 181 ms
24,524 KB |
testcase_29 | AC | 218 ms
22,508 KB |
testcase_30 | AC | 91 ms
24,528 KB |
testcase_31 | AC | 223 ms
22,540 KB |
testcase_32 | AC | 230 ms
22,496 KB |
testcase_33 | TLE | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ N = S.Length; int[] ll = new int[27]; var dl = new Dictionary<char, int>[27]; for(int i=0;i<27;i++) dl[i] = new Dictionary<char,int>(); long cnt = 0; for(int i=0;i<N;i++){ for(int len=0;len<=26;len++){ if(ll[len] < i) ll[len] = i; while(ll[len] < N){ if(dl[len].ContainsKey(S[ll[len]])){ dl[len][S[ll[len]]]++; ll[len]++; continue; } if(dl[len].Count < len){ dl[len].Add(S[ll[len]], 1); ll[len]++; continue; } break; } } for(int len = 1; len <= 26; len++){ if(dl[len].Count == len){ cnt += (long)len * (long)(ll[len] - ll[len - 1]); } } for(int len = 0; len <= 26; len++){ if(dl[len].ContainsKey(S[i])){ dl[len][S[i]]--; if(dl[len][S[i]] == 0) dl[len].Remove(S[i]); } } } double tot = (double) N * (double) (N + 1) / 2.0; Console.WriteLine((double)cnt / tot); } int N; String S; public Sol(){ S = rs(); } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }