結果
| 問題 |
No.852 連続部分文字列
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2019-07-26 23:20:07 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,822 bytes |
| コンパイル時間 | 855 ms |
| コンパイル使用メモリ | 113,332 KB |
| 実行使用メモリ | 31,312 KB |
| 最終ジャッジ日時 | 2024-07-02 09:43:23 |
| 合計ジャッジ時間 | 9,139 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 TLE * 1 -- * 10 |
コンパイルメッセージ
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>();
double 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 += (double)len * (double)(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(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));}
}
kuuso1