結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー kotatsugamekotatsugame
提出日時 2021-11-06 00:31:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 66,680 KB
実行使用メモリ 44,544 KB
最終ジャッジ日時 2024-04-24 09:48:37
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 121 ms
5,376 KB
testcase_38 AC 126 ms
5,376 KB
testcase_39 AC 121 ms
5,376 KB
testcase_40 AC 128 ms
5,376 KB
testcase_41 AC 121 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 37 ms
44,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
string X,Y;
int Yc[1<<17][26];
int RYc[1<<17][26];
int Xc[1<<17][26];
int RXc[1<<17][26];
int cnt[50][27];
int f(int i,int N,int k,bool rev)
{
	if(i==0)
	{
		return Xc[N][k];
	}
	if(cnt[i-1][26]>=N)
	{
		return f(i-1,N,k,false);
	}
	else if(cnt[i-1][26]+Y.size()>=N)
	{
		int ret=cnt[i-1][k];
		N-=cnt[i-1][26];
		ret+=(rev?RYc:Yc)[N][k];
		return ret;
	}
	else
	{
		int ret=cnt[i-1][k]+Yc[Y.size()][k];
		N-=cnt[i-1][26]+Y.size();
		ret+=f(i-1,N,k,!rev);
		return ret;
	}
}
main()
{
	cin>>X>>Y;
	for(int i=0;i<X.size();i++)
	{
		for(int j=0;j<26;j++)
		{
			Xc[i+1][j]=Xc[i][j];
		}
		Xc[i+1][X[i]-'a']++;
	}
	for(int i=0;i<X.size();i++)
	{
		for(int j=0;j<26;j++)
		{
			RXc[i+1][j]=RXc[i][j];
		}
		RXc[i+1][X[X.size()-i-1]-'a']++;
	}
	for(int i=0;i<Y.size();i++)
	{
		for(int j=0;j<26;j++)
		{
			Yc[i+1][j]=Yc[i][j];
		}
		Yc[i+1][Y[i]-'a']++;
	}
	for(int i=0;i<Y.size();i++)
	{
		for(int j=0;j<26;j++)
		{
			RYc[i+1][j]=RYc[i][j];
		}
		RYc[i+1][Y[Y.size()-i-1]-'a']++;
	}
	for(int j=0;j<26;j++)cnt[0][j]=Xc[X.size()][j];
	cnt[0][26]=X.size();
	int mx=1;
	for(;;)
	{
		int i=mx;
		for(int j=0;j<27;j++)
		{
			cnt[i][j]=cnt[i-1][j]*2+(j<26?Yc[Y.size()][j]:Y.size());
		}
		if(cnt[i][26]>=(int)1e9)break;
		mx++;
	}
	int Q;cin>>Q;
	for(;Q--;)
	{
		int l,r;char c;
		cin>>l>>r>>c;
		int op=c-'a';
		cout<<f(mx,r,op,false)-f(mx,l-1,op,false)<<endl;
	}
}
0