QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#493051#9155. 集合Erinyes100 ✓458ms77908kbC++141.4kb2024-07-26 19:01:322024-07-26 19:01:32

Judging History

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

  • [2024-07-26 19:01:32]
  • 评测
  • 测评结果:100
  • 用时:458ms
  • 内存:77908kb
  • [2024-07-26 19:01:32]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define ull unsigned long long
using namespace std;
const int P=10007;
int n,m,q;
int p[22][200005],vst[2][600005];
ull HS[2],pw[200005],hs[2][600005];
struct node{int a,b,c;}a[200005],b[200005];
mt19937 rd(time(0));
unordered_map<ull,ull>g;
inline ull H(ull val){
	if(g.find(val)!=g.end())return g[val];
	return g[val]=((ull)rd()<<32)+rd();
}
inline void ins(int x,int id,int k,int op){
	if(vst[op][x])HS[op]-=H(hs[op][x]);
	hs[op][x]+=pw[id]*k,vst[op][x]+=k;
	if(vst[op][x])HS[op]+=H(hs[op][x]);
}
inline void add(int x,int k){
	ins(a[x].a,x,k,0),ins(a[x].b,x,k,0),ins(a[x].c,x,k,0);
	ins(b[x].a,x,k,1),ins(b[x].b,x,k,1),ins(b[x].c,x,k,1);
}
inline int ask(int l,int r){
	int k=__lg(r-l+1);
	return min(p[k][l],p[k][r-(1<<k)+1]);
}
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("ex_4.in","r",stdin);
	freopen(".out","w",stdout);
	#endif
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>q,pw[0]=1;
	for(int i=1;i<=n;i++)cin>>a[i].a>>a[i].b>>a[i].c,pw[i]=pw[i-1]*P;
	for(int i=1;i<=n;i++)cin>>b[i].a>>b[i].b>>b[i].c;
	for(int i=1,j=0;i<=n;i++){
		while(j<=n&&HS[0]==HS[1])add(++j,1);
		assert(i<=j);
		p[0][i]=j-1,add(i,-1);
	}
	for(int j=1;(1<<j)<=n;j++){
		for(int i=1;i+(1<<j)-1<=n;i++){
			p[j][i]=min(p[j-1][i],p[j-1][i+(1<<j-1)]);
		}
	}
	while(q--){
		int l,r;cin>>l>>r;
		cout<<(ask(l,r)>=r?"Yes":"No")<<endl;
	}
	return 0;
}

Details


Pretests

Pretest #1:

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

Pretest #2:

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

Pretest #3:

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

Pretest #4:

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

Pretest #5:

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

Pretest #6:

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

Pretest #7:

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

Pretest #8:

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

Pretest #9:

score: 5
Accepted
time: 19ms
memory: 13928kb

Pretest #10:

score: 5
Accepted
time: 24ms
memory: 13956kb

Pretest #11:

score: 5
Accepted
time: 360ms
memory: 70324kb

Pretest #12:

score: 5
Accepted
time: 363ms
memory: 69500kb

Pretest #13:

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

Pretest #14:

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

Pretest #15:

score: 5
Accepted
time: 116ms
memory: 16328kb

Pretest #16:

score: 5
Accepted
time: 112ms
memory: 16744kb

Pretest #17:

score: 5
Accepted
time: 16ms
memory: 28608kb

Pretest #18:

score: 5
Accepted
time: 20ms
memory: 25412kb

Pretest #19:

score: 5
Accepted
time: 443ms
memory: 68872kb

Pretest #20:

score: 5
Accepted
time: 445ms
memory: 77676kb

Final Tests

Test #1:

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

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

score: 5
Accepted
time: 19ms
memory: 13980kb

Test #10:

score: 5
Accepted
time: 19ms
memory: 16252kb

Test #11:

score: 5
Accepted
time: 366ms
memory: 71608kb

Test #12:

score: 5
Accepted
time: 311ms
memory: 70972kb

Test #13:

score: 5
Accepted
time: 5ms
memory: 18452kb

Test #14:

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

Test #15:

score: 5
Accepted
time: 99ms
memory: 18472kb

Test #16:

score: 5
Accepted
time: 112ms
memory: 18560kb

Test #17:

score: 5
Accepted
time: 16ms
memory: 26492kb

Test #18:

score: 5
Accepted
time: 20ms
memory: 25332kb

Test #19:

score: 5
Accepted
time: 458ms
memory: 69520kb

Test #20:

score: 5
Accepted
time: 446ms
memory: 77908kb

Extra Test:

score: 0
Extra Test Passed