結果

問題 No.603 hel__world (2)
ユーザー tailstails
提出日時 2017-12-03 05:16:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,254 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 175,080 KB
実行使用メモリ 19,968 KB
最終ジャッジ日時 2024-05-06 04:52:25
合計ジャッジ時間 14,118 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 210 ms
17,000 KB
testcase_01 AC 205 ms
7,424 KB
testcase_02 AC 201 ms
7,296 KB
testcase_03 AC 202 ms
7,424 KB
testcase_04 AC 203 ms
7,552 KB
testcase_05 AC 207 ms
7,424 KB
testcase_06 AC 201 ms
7,552 KB
testcase_07 AC 201 ms
7,424 KB
testcase_08 WA -
testcase_09 AC 202 ms
7,296 KB
testcase_10 AC 198 ms
7,424 KB
testcase_11 AC 288 ms
10,128 KB
testcase_12 AC 286 ms
9,988 KB
testcase_13 AC 290 ms
9,996 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 207 ms
7,424 KB
testcase_20 AC 237 ms
8,448 KB
testcase_21 AC 233 ms
8,448 KB
testcase_22 AC 199 ms
7,424 KB
testcase_23 AC 201 ms
7,424 KB
testcase_24 AC 208 ms
7,424 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define MD 1000003

long long 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;
	int mc=0;
	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),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)/(xnnn[n]+1-xlen[n]),n));
			int t=xnnn[n];
			while(t%MD==0){
				t/=MD;
				++mc;
			}
			r=(long long)r*t%MD;
			t=xnnn[n]-xlen[n];
			while(t%MD==0){
				t/=MD;
				--mc;
			}
			r=(long long)r*inv[t]%MD;
		}
		if(mc){
			cout<<0;
			exit(0);
		}
	}
	cout<<r;
}
0