結果
問題 |
No.852 連続部分文字列
|
ユーザー |
|
提出日時 | 2019-07-27 20:53:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 572 bytes |
コンパイル時間 | 598 ms |
コンパイル使用メモリ | 70,528 KB |
実行使用メモリ | 110,596 KB |
最終ジャッジ日時 | 2024-07-02 11:15:06 |
合計ジャッジ時間 | 13,134 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 RE * 31 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#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; }