結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー 👑 kmjpkmjp
提出日時 2021-10-31 15:11:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,883 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 196,888 KB
実行使用メモリ 24,104 KB
最終ジャッジ日時 2024-04-17 08:02:41
合計ジャッジ時間 6,695 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
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 101 ms
6,940 KB
testcase_38 AC 97 ms
6,944 KB
testcase_39 AC 100 ms
6,944 KB
testcase_40 AC 99 ms
6,940 KB
testcase_41 AC 100 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 11 ms
24,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


string X,Y;
int A,B;
ll H[60],sum[60][26];

int S[101010][26];
int T[101010][26];
int Q;
int C;

ll hoge(int cur,ll num,int rev) {
	if(num>=H[cur]) {
		return sum[cur][C];
	}
	
	if(cur==1) {
		if(rev==0) return S[num][C];
		else return S[A][C]-S[A-num][C];
	}
	else if(num<=H[cur-1]){
		return hoge(cur-1,num,rev);
	}
	else if(num<=H[cur-1]+B) {
		ll pat=sum[cur-1][C];
		num-=H[cur-1];
		if(rev==0) pat+=T[num][C];
		else pat+=T[B][C]-T[B-num][C];
		return pat;
	}
	else {
		ll pat=sum[cur-1][C]+T[B][C];
		num-=H[cur-1]+B;
		return pat+hoge(cur-1,num,rev^1);
	}
	
	
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>Y;
	A=X.size();
	B=Y.size();
	FOR(i,A) {
		FOR(j,26) S[i+1][j]=S[i][j];
		S[i+1][X[i]-'a']++;
	}
	FOR(i,B) {
		FOR(j,26) T[i+1][j]=T[i][j];
		T[i+1][Y[i]-'a']++;
	}
	H[1]=A;
	FOR(j,26) sum[1][j]=S[A][j];
	for(i=2;i<=40;i++) {
		H[i]=min(1LL<<60,H[i-1]*2+B);
		FOR(j,26) {
			sum[i][j]=min(1LL<<60,sum[i-1][j]*2+T[B][j]);
			
		}
	}
	
	cin>>Q;
	while(Q--) {
		int L,R;
		cin>>L>>R>>s;
		C=s[0]-'a';
		cout<<hoge(31,R,0)-hoge(31,L-1,0)<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0