QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449827#5014. 复读程度szzjz0 914ms15704kbC++141.6kb2024-06-21 17:59:062024-06-21 17:59:06

Judging History

你现在查看的是最新测评结果

  • [2024-06-21 17:59:06]
  • 评测
  • 测评结果:0
  • 用时:914ms
  • 内存:15704kb
  • [2024-06-21 17:59:06]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
#define pub emplace_back
using namespace std;
#include<bits/extc++.h>
using namespace __gnu_pbds;
const int N=1e5+10;
const int P=131;
typedef unsigned long long ull;
int n,qs;
ull val[N],cf[N];
char s[N];
ull wl[N],wr[N];
int scf;
ull read(){
	ull x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x;
}
void write(ull x){
	if(x>10) write(x/10);
	putchar(x%10^48);
}
inline ull ask(int l,int r){
	return val[r]-val[l-1]*cf[r-l+1];
}
ull solve(ull v1,int l1,ull v2,int l2){
	vector<int> p1,p2;
	for(int i=1;i+l1-1<=n;i++)
		if(ask(i,i+l1-1)==v1) p1.pub(i);
	for(int i=1;i+l2-1<=n;i++)
		if(ask(i,i+l2-1)==v2) p2.pub(i+l2-1);
	gp_hash_table<ull,pair<pair<ull,ull>,int>> mp;
	int j=0;
	for(int l:p1){
		while(j<p2.size()&&p2[j]-l+1<max(l1,l2)) j++;
		for(int i=j;i<p2.size();i++){
			int r=p2[i];ull v=ask(l,r);
		//	cout<<l<<" "<<r<<endl;
			mp[v].fi.fi+=wl[l];
			mp[v].fi.se+=wr[r];
			mp[v].se++;
		}
	}
	ull ans=0;
	for(auto it:mp) ans+=it.se.fi.fi*it.se.fi.se*it.se.se;
	return ans;
}
int main(){
	scf=scanf("%d %d %s",&n,&qs,s+1);
	for(int i=1;i<=n;i++) val[i]=val[i-1]*P+s[i]-'a'+1;
	cf[0]=1;for(int i=1;i<=n;i++) cf[i]=cf[i-1]*P;
	for(int i=1;i<=n;i++) wl[i]=read();
	for(int i=1;i<=n;i++) wr[i]=read();
	for(int id=1;id<=qs;id++){
		int l1,r1,l2,r2;
		scf=scanf("%d %d %d %d",&l1,&r1,&l2,&r2);
		write(solve(ask(l1,r1),r1-l1+1,ask(l2,r2),r2-l2+1));
		puts("");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 914ms
memory: 15704kb

input:

500 500
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

15720454042420499810
4058077030882532408
14651762045124606089
4030024243931986061
18033423360813892607
9470601111824364484
3883374861354698625
16650831689368240202
8339028189650687576
2683289915379600554
13133811958066776394
14181220923901262251
18173739360450512256
13142314545999179754
148925491596...

result:

wrong answer 39th lines differ - expected: '10477096436968491709', found: '0477096436968491709'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #22:

score: 0
Time Limit Exceeded

input:

100000 100000
zbbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

16102224067619618967
4136909955563952986
427496158535942638
3803647360928510876
9612725428377010375
16283030984784184667
14966758574838045581
8108029333542434517
5821899279772898061
7354415533246368927
15016230232022193055
9072126619623269970
5490256818353051548
7472286196545953474
13681741566473101...

result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%