QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492757#9155. 集合dyj133446100 ✓290ms55192kbC++141.6kb2024-07-26 15:48:292024-07-26 15:48:31

Judging History

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

  • [2024-07-26 15:48:31]
  • 评测
  • 测评结果:100
  • 用时:290ms
  • 内存:55192kb
  • [2024-07-26 15:48:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mod1=998244353,mod2=1e9+7;
mt19937 rnd(time(0));
long long n,m,q,a[3*N],b[3*N],val1[N],val2[N],cnta1[3*N],cntb1[3*N],cnta2[3*N],cntb2[3*N],L[5*N],R[5*N],maxx[3*N];
long long sum1,sum2;
void add(int x,int y)
{
	for(int i=0;i<3;i++)
	{
		int tmp1=a[3*x-i],tmp2=b[3*x-i];
		sum1-=1ll*cnta1[tmp1]*cnta1[tmp1]%mod1*cnta1[tmp1]%mod1;
		cnta1[tmp1]=(cnta1[tmp1]+mod1+y*val1[x])%mod1;
		sum1+=1ll*cnta1[tmp1]*cnta1[tmp1]%mod1*cnta1[tmp1]%mod1;
		sum2-=1ll*cnta2[tmp1]*cnta2[tmp1]%mod2*cnta2[tmp1]%mod2;
		cnta2[tmp1]=(cnta2[tmp1]+mod2+y*val2[x])%mod2;
		sum2+=1ll*cnta2[tmp1]*cnta2[tmp1]%mod2*cnta2[tmp1]%mod2;
		sum1+=1ll*cntb1[tmp2]*cntb1[tmp2]%mod1*cntb1[tmp2]%mod1;
		cntb1[tmp2]=(cntb1[tmp2]+mod1+y*val1[x])%mod1;
		sum1-=1ll*cntb1[tmp2]*cntb1[tmp2]%mod1*cntb1[tmp2]%mod1;
		sum2+=1ll*cntb2[tmp2]*cntb2[tmp2]%mod2*cntb2[tmp2]%mod2;
		cntb2[tmp2]=(cntb2[tmp2]+mod2+y*val2[x])%mod2;
		sum2-=1ll*cntb2[tmp2]*cntb2[tmp2]%mod2*cntb2[tmp2]%mod2;
	}
}
bool check(int x)
{
	add(x,1);
	bool flag=!sum1&&!sum2;
	add(x,-1);
	return flag;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m>>q;
	for(int i=1;i<=3*n;i++)cin>>a[i];
	for(int i=1;i<=3*n;i++)cin>>b[i];
	for(int i=1;i<=q;i++)cin>>L[i]>>R[i];
	for(int i=1;i<=n;i++)val1[i]=rnd()%mod1+1,val2[i]=rnd()%mod2+1;
	int r=1;
	for(int i=1;i<=n;i++)
	{
		while(r<=n&&check(r))add(r,1),r++;
		maxx[i]=r-1,add(i,-1);
		if(r==i)r++;
	}
	for(int i=1;i<=q;i++)
	{
		if(R[i]<=maxx[L[i]])cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

Details


Pretests

Pretest #1:

score: 5
Accepted
time: 2ms
memory: 13904kb

Pretest #2:

score: 5
Accepted
time: 0ms
memory: 15992kb

Pretest #3:

score: 5
Accepted
time: 2ms
memory: 15956kb

Pretest #4:

score: 5
Accepted
time: 0ms
memory: 15936kb

Pretest #5:

score: 5
Accepted
time: 1ms
memory: 13888kb

Pretest #6:

score: 5
Accepted
time: 1ms
memory: 14032kb

Pretest #7:

score: 5
Accepted
time: 0ms
memory: 14032kb

Pretest #8:

score: 5
Accepted
time: 0ms
memory: 14036kb

Pretest #9:

score: 5
Accepted
time: 21ms
memory: 20096kb

Pretest #10:

score: 5
Accepted
time: 22ms
memory: 13972kb

Pretest #11:

score: 5
Accepted
time: 144ms
memory: 24064kb

Pretest #12:

score: 5
Accepted
time: 147ms
memory: 28672kb

Pretest #13:

score: 5
Accepted
time: 2ms
memory: 16008kb

Pretest #14:

score: 5
Accepted
time: 4ms
memory: 16160kb

Pretest #15:

score: 5
Accepted
time: 96ms
memory: 30352kb

Pretest #16:

score: 5
Accepted
time: 101ms
memory: 28524kb

Pretest #17:

score: 5
Accepted
time: 12ms
memory: 16244kb

Pretest #18:

score: 5
Accepted
time: 18ms
memory: 18072kb

Pretest #19:

score: 5
Accepted
time: 256ms
memory: 36768kb

Pretest #20:

score: 5
Accepted
time: 290ms
memory: 52840kb

Final Tests

Test #1:

score: 5
Accepted
time: 3ms
memory: 16028kb

Test #2:

score: 5
Accepted
time: 0ms
memory: 16080kb

Test #3:

score: 5
Accepted
time: 0ms
memory: 13948kb

Test #4:

score: 5
Accepted
time: 2ms
memory: 13972kb

Test #5:

score: 5
Accepted
time: 0ms
memory: 14024kb

Test #6:

score: 5
Accepted
time: 2ms
memory: 15952kb

Test #7:

score: 5
Accepted
time: 0ms
memory: 15956kb

Test #8:

score: 5
Accepted
time: 2ms
memory: 15992kb

Test #9:

score: 5
Accepted
time: 22ms
memory: 20168kb

Test #10:

score: 5
Accepted
time: 22ms
memory: 20168kb

Test #11:

score: 5
Accepted
time: 146ms
memory: 26456kb

Test #12:

score: 5
Accepted
time: 138ms
memory: 26628kb

Test #13:

score: 5
Accepted
time: 4ms
memory: 16148kb

Test #14:

score: 5
Accepted
time: 3ms
memory: 14224kb

Test #15:

score: 5
Accepted
time: 87ms
memory: 28300kb

Test #16:

score: 5
Accepted
time: 92ms
memory: 28520kb

Test #17:

score: 5
Accepted
time: 13ms
memory: 16112kb

Test #18:

score: 5
Accepted
time: 13ms
memory: 18032kb

Test #19:

score: 5
Accepted
time: 248ms
memory: 38928kb

Test #20:

score: 5
Accepted
time: 278ms
memory: 55192kb

Extra Test:

score: 0
Extra Test Passed