結果
| 問題 |
No.603 hel__world (2)
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2017-12-03 04:12:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,126 bytes |
| コンパイル時間 | 1,682 ms |
| コンパイル使用メモリ | 173,824 KB |
| 実行使用メモリ | 13,324 KB |
| 最終ジャッジ日時 | 2024-11-28 08:26:03 |
| 合計ジャッジ時間 | 11,343 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 11 |
コンパイルメッセージ
main.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
34 | main(){
| ^~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define MD 1000003
int S[26];
char T[1000010];
int xlen[1000010];
int xnnn[1000010];
int inv[1000010];
int get_inv(long long a, int md){
long long e, s=md, t=a, u=1, v=0;
while(s){
e=t/s;
t-=e*s;
u-=e*v;
swap(t,s);
swap(u,v);
}
if(u<0){
u+=md;
}
return u;
}
void mkinv(){
for(int i=1;i<MD;++i){
inv[i]=get_inv(i,MD);
}
}
main(){
mkinv();
for(int c=0;c<26;++c){
cin>>S[c];
}
cin>>T;
int tlen=strlen(T);
int r=1;
for(int c=0;c<26;++c){
priority_queue<pair<double,int>> pq;
int n=0;
int st=-1;
for(int i=0;i<=tlen;++i){
if(T[i]==c+'a'){
if(st<0){
st=i;
}
}else{
if(st>=0){
int xl=i-st;
xlen[n]=xl;
xnnn[n]=xl;
pq.push(make_pair(-1.*(xl+1)/xl,n));
++n;
if((S[c]-=xl)<0){
cout<<0;
exit(0);
}
st=-1;
}
}
}
if(n)
while(S[c]--){
auto p=pq.top();pq.pop();
n=p.second;
++xnnn[n];
pq.push(make_pair(-1.*(xnnn[n]+1)/xlen[n],n));
r=(long long)r*xnnn[n]%MD;
r=(long long)r*inv[xnnn[n]-xlen[n]]%MD;
if(r==0){
cout<<0;
exit(0);
}
}
}
cout<<r;
}
tails