結果

問題 No.852 連続部分文字列
ユーザー kotatsugamekotatsugame
提出日時 2019-07-27 20:53:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 572 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 71,520 KB
実行使用メモリ 110,884 KB
最終ジャッジ日時 2023-09-15 06:41:44
合計ジャッジ時間 13,234 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
54,880 KB
testcase_01 AC 11 ms
54,760 KB
testcase_02 AC 11 ms
54,872 KB
testcase_03 AC 12 ms
54,740 KB
testcase_04 AC 11 ms
54,872 KB
testcase_05 AC 11 ms
54,868 KB
testcase_06 AC 11 ms
54,736 KB
testcase_07 AC 10 ms
54,864 KB
testcase_08 AC 10 ms
54,696 KB
testcase_09 AC 11 ms
54,752 KB
testcase_10 AC 11 ms
54,880 KB
testcase_11 AC 11 ms
54,792 KB
testcase_12 AC 11 ms
54,672 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;
string s;
int prv[26][1<<20],now[26];
double ans;
main()
{
	cin>>s;
	for(int i=0;i<26;i++)now[i]=-1;
	for(int i=0;i<s.size();i++)
	{
		for(int j=0;j<26;j++)prv[j][i]=now[j];
		int cnt=1<<s[i]-'a';
		int p=i;
		while(p>=0)
		{
			int id=-1;
			for(int j=0;j<26;j++)
			{
				if(cnt>>j&1)continue;
				if(id<0||prv[id][p]<prv[j][p])id=j;
			}
			ans+=__builtin_popcount(cnt)*(p-prv[id][p]);
			p=prv[id][p];
			if(id>=0)
			{
				cnt|=1<<id;
			}
		}
		now[s[i]-'a']=i;
	}
	cout<<ans*2/s.size()/(s.size()+1)<<endl;
}
0