QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#874679#9689. 伪伪随机JohnAlfnov#20 4463ms4992kbC++142.7kb2025-01-28 13:29:592025-01-28 13:30:04

Judging History

This is the latest submission verdict.

  • [2025-01-28 13:30:04]
  • Judged
  • Verdict: 20
  • Time: 4463ms
  • Memory: 4992kb
  • [2025-01-28 13:29:59]
  • Submitted

answer

#include "prg.h"
#include<bits/stdc++.h>
using namespace std;
int fa[1005];
int findfather(int x){
	return x==fa[x]?x:fa[x]=findfather(fa[x]);
}
vector<pair<int,int>>g[1005];
int dj[3005],dist[1005];
void dfs(int x,int la){
	for(auto pi:g[x]){
		int cu=pi.first,c2=pi.second;
		if(cu==la)continue;
		dist[cu]=dist[x]^dj[c2];
		dfs(cu,x);
	}
}
int dep[1005],af[21][1005];
void dfss(int x,int la){
	for(auto pi:g[x]){
		int cu=pi.first;
		if(cu==la)continue;
		dep[cu]=dep[x]+1;af[0][cu]=x;
		dfss(cu,x);
	}
}
int lca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	for(int i=9;i>=0;--i)if(dep[x]-dep[y]>=(1<<i))x=af[i][x];
	if(x==y)return x;
	for(int i=9;i>=0;--i)if(af[i][x]!=af[i][y])x=af[i][x],y=af[i][y];
	return af[0][x];
}
int suan(int u,int v){
	int l=lca(u,v);
	return dep[u]+dep[v]-2*dep[l];
}
int solve(int n,int m,int k,vector<int>op,array<vector<int>,3000>x,int c,array<array<int,3000>,25>s){
	if(k==2){
		int a1=0,a2=0;
		for(int i=0;i<c;++i){
			int h=0;
			for(int j=0;j<m;++j){
				h+=s[i][j];
			}
			if(h>=(m/4+m/2)/2&&h<=(m*3/4+m/2)/2)++a1;
			else ++a2;
		}
		return (a2<=1?1:2);
	}
	if(op[k-2]!=2){
		int a1=0,a2=0;
		for(int i=0;i<c;++i){
			int h=0;
			for(int j=0;j<m;++j){
				h+=s[i][j];
			}
			if(h>=m/2-m/16&&h<=m/2+m/16)++a1;
			else ++a2;
		}
		return (a2<=1?1:2);
	}
	if(op[k-3]!=2){
		vector<vector<int>>gs(n);
		for(int i=0;i<m;++i){
			gs[x[i][k-1]].emplace_back(i);
		}
		int mn=0,ms=0;
		for(int i=0;i<n;++i)if((signed)gs[i].size()>=2){
			int t=gs[i].size(),kn=0;
			for(int j=0;j<c;++j){
				int h=0;
				for(auto k:gs[i]){
					h+=s[j][k];
				}
				if(h==0||h==t)++kn;
			}
			mn+=kn;++ms;
		}
		if(1.0*mn/ms>6.7)return 2;
		return 1;
	}
	if(op[0]==1){
		for(int i=0;i<c;++i){
			for(int j=0;j<m;++j){
				s[i][j]^=1;
			}
		}
	}
	int he=0,gs=0;
	int TT=100;
	mt19937 mt(13770618);
	while(TT--){
		vector<int>ok(m),p(m);
		for(int i=0;i<n;++i)fa[i]=i,g[i].clear();
		for(int i=0;i<m;++i)p[i]=i;
		shuffle(p.begin(),p.end(),mt);
		for(int ii=0;ii<m;++ii){
			int i=p[ii];
			int u=x[i][2],v=x[i][3];
			int fu=findfather(u),fv=findfather(v);
			if(fu!=fv){
				fa[fu]=fv;
				g[u].emplace_back(v,i);
				g[v].emplace_back(u,i);
			}else{
				ok[i]=1;
			}
		}
		dep[0]=0;af[0][0]=af[0][n]=n;dfss(0,-1);
		for(int i=1;i<=10;++i)for(int j=0;j<=n;++j)
			af[i][j]=af[i-1][af[i-1][j]];
		for(int i=0;i<m;++i){
			if(ok[i]&&suan(x[i][2],x[i][3])>2)ok[i]=0;
		}
		for(int t=0;t<c;++t){
			for(int i=0;i<m;++i){
				dj[i]=s[t][i];
			}
			dfs(0,-1);
			for(int i=0;i<m;++i)if(ok[i]){
				int u=x[i][2],v=x[i][3];
				he+=dj[i]^dist[u]^dist[v];++gs;
			}
		}
	}
	printf("%.10f\n",1.0*he/gs);
	if(1.0*he/gs<0.452)return 2;
	return 1;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 37ms
memory: 4608kb

input:

15478345200793503450
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #2:

score: 5
Accepted
time: 36ms
memory: 4480kb

input:

8777328773999050296
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #3:

score: 5
Accepted
time: 38ms
memory: 4480kb

input:

8306860370301473558
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #4:

score: 5
Accepted
time: 38ms
memory: 4608kb

input:

7355535262167792602
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #5:

score: 5
Accepted
time: 38ms
memory: 4608kb

input:

5901033176077457090
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #6:

score: 5
Accepted
time: 37ms
memory: 4480kb

input:

6725216784977925179
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #7:

score: 5
Accepted
time: 37ms
memory: 4480kb

input:

15228205213107479514
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #8:

score: 5
Accepted
time: 38ms
memory: 4608kb

input:

10794704323727532585
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #9:

score: 5
Accepted
time: 38ms
memory: 4480kb

input:

1531863096801291235
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #10:

score: 5
Accepted
time: 37ms
memory: 4480kb

input:

12583269177593428071
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #11:

score: 5
Accepted
time: 38ms
memory: 4480kb

input:

17884260014537450829
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #12:

score: 5
Accepted
time: 38ms
memory: 4480kb

input:

5598933293992250528
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #13:

score: 5
Accepted
time: 37ms
memory: 4608kb

input:

15029988260575536839
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #14:

score: 5
Accepted
time: 39ms
memory: 4480kb

input:

18435900855108017468
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #15:

score: 5
Accepted
time: 36ms
memory: 4480kb

input:

4740054765891404200
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #16:

score: 5
Accepted
time: 39ms
memory: 4608kb

input:

14854659461851577578
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #17:

score: 5
Accepted
time: 39ms
memory: 4480kb

input:

11860421814773748892
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #18:

score: 5
Accepted
time: 36ms
memory: 4352kb

input:

2618043996784533224
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #19:

score: 5
Accepted
time: 36ms
memory: 4608kb

input:

4729099511370153840
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #20:

score: 5
Accepted
time: 37ms
memory: 4480kb

input:

6142100148239098773
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Subtask #2:

score: 15
Accepted

Test #21:

score: 15
Accepted
time: 58ms
memory: 4608kb

input:

15644456504653888385
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #22:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

17525409403797767860
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #23:

score: 15
Accepted
time: 54ms
memory: 4608kb

input:

16953002163903257386
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #24:

score: 15
Accepted
time: 54ms
memory: 4608kb

input:

788278265436010907
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #25:

score: 15
Accepted
time: 55ms
memory: 4608kb

input:

15540481379750277983
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #26:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

9015247799051510708
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #27:

score: 15
Accepted
time: 55ms
memory: 4480kb

input:

14718463813137865720
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #28:

score: 15
Accepted
time: 42ms
memory: 4480kb

input:

9626039215908894536
1237461 18364524
21312415 32673239

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #29:

score: 15
Accepted
time: 41ms
memory: 4480kb

input:

15367994199069034681
1237461 18364524
21312414 32673236

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #30:

score: 15
Accepted
time: 54ms
memory: 4608kb

input:

9815994743565449906
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #31:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

5076972403022378194
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #32:

score: 15
Accepted
time: 55ms
memory: 4608kb

input:

13523311479884920883
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #33:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

15452059373617333584
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #34:

score: 15
Accepted
time: 55ms
memory: 4608kb

input:

8631381148034308695
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #35:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

5422315179829169150
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #36:

score: 15
Accepted
time: 54ms
memory: 4608kb

input:

4361249126136426961
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #37:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

6976800422460576686
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #38:

score: 15
Accepted
time: 55ms
memory: 4608kb

input:

8552184079474065172
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #39:

score: 15
Accepted
time: 55ms
memory: 4608kb

input:

1598183902825082255
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #40:

score: 15
Accepted
time: 56ms
memory: 4608kb

input:

3317147437384062467
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Subtask #3:

score: 0
Wrong Answer

Test #41:

score: 0
Wrong Answer
time: 406ms
memory: 4992kb

input:

18096446825184275106
1237458 18364525

output:

0.4859345794
0.5327577093
0.4808551992
0.5074463360
0.5165853659
0.4065724907
0.5063558664
0.4102181818
126534127

result:

wrong output format Expected integer, but "0.4859345794" found

Subtask #4:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 4463ms
memory: 4992kb

input:

6934415118162240981
1237458 18364524
21312414 32673238 236176120

output:

0.4177202910
0.3844003777
0.4349655851
0.3894921191
0.4069416342
0.4844019139
0.4096177901
0.4743986254
0.4090140845
0.4072183099
0.5023712949
0.4883381364
0.4340740741
0.5366000000
0.4872675250
0.4956321839
0.4977003484
0.5054545455
0.3858024691
0.4632766615
0.4754449761
0.3931137725
0.4069510926
0...

result:

wrong output format Expected integer, but "0.4177202910" found