QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#934427#9689. 伪伪随机csyakuoi38.112781 409ms43528kbC++142.8kb2025-03-14 19:20:032025-03-14 19:20:03

Judging History

This is the latest submission verdict.

  • [2025-03-14 19:20:03]
  • Judged
  • [2025-03-14 19:20:03]
  • Submitted

answer

#include"prg.h"
#include<vector>
#include<cmath>
#include<ctime>
#include<cstdlib>
using namespace std;
double solve(int n,int m,double p)
{
	double a=1,b=1,c=1,d=1;
	for(int i=0;i<m;i++){
		a*=p; c*=1-p;
	}
	for(int i=0;i<n-m;i++){
		b*=1-p; d*=p;
	}
	return log2(a*b+c*d);
}

vector<int> to[1000],id[1000];
vector<int> ed[1000][1000];

int solve(int n,int m,int k,vector<int> op,array<vector<int>,3000> arr,int T,array<array<int,3000>,25> res)
{
	if(op[k-2]!=2){
		int cnt=0;
		for(int i=0;i<T;i++)
			for(int j=0;j<m;j++)
				cnt+=res[i][j];
		if(cnt<35000||cnt>40000)
			return 2;
		return 1;
	}
	for(int i=0;i<n;i++)
		id[i].clear();
	if(k<4||op[1]!=2){
		double p1=0.5,p2=0.75;
		if(k==4&&op[0]!=2&&op[1]!=2){
			if(op[1]==op[2]) p2=0.875;
			else p2=0.625;
		}
		double E1=0.0,E2=0.0;
		for(int i=0;i<m;i++)
			id[arr[i][k-1]].push_back(i);
		for(int i=0;i<n;i++)
			for(int t=0;t<T;t++){
				int p=id[i].size(),cnt=0;
				for(int j=0;j<p;j++)
					cnt+=res[t][id[i][j]];
				E1+=solve(p,cnt,p1);
				E2+=solve(p,cnt,p2);
			}
		if(E2>E1) return 2;
		return 1;
	}
	double E1=0.0,E2=0.0;
	for(int i=0;i<n;i++){
		to[i].clear();
		for(int j=i;j<n;j++)
			ed[i][j].clear();
	}
	for(int i=0;i<m;i++){
		int a=arr[i][2],b=arr[i][3];
		to[a].push_back(b);
		to[b].push_back(a);
		id[a].push_back(i);
		id[b].push_back(i);
		if(a>b) swap(a,b);
		ed[a][b].push_back(i);
	}
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(ed[i][j].size()>=2){
				int c0=ed[i][j][0],c1=ed[i][j][1];
				for(int t=0;t<T;t++){
					E2-=1.0;
					if(res[t][c0]==res[t][c1]) E1+=log2(0.625);
					else E1+=log2(0.375);
				}
			}
	double U=log2(0.5625),V=log2(0.4375);
	for(int i=0;i<n;i++)
		for(int j=0;j<to[i].size();j++)
			for(int k=j+1;k<to[i].size();k++){
				int x=to[i][j],y=to[i][k];
				if(x>y) swap(x,y);
				if(ed[x][y].size()>=1){
					int a=ed[x][y][0];
					int b=id[i][j],c=id[i][k];
					for(int t=0;t<T;t++){
						int v=res[t][a]^res[t][b]^res[t][c];
						E2-=1.0;
						if(op[0]^v) E1+=V;
						else E1+=U;
					}
				}
			}
	U=log2(15.0/32); V=log2(17.0/32);
	U*=1.01; V*=1.01;
	for(int i=0;i<n;i++)
		for(int j=i;j<n;j++)
			ed[i][j].clear();
	for(int i=0;i<n;i++)
		for(int j=0;j<to[i].size();j++)
			for(int k=j+1;k<to[i].size();k++){
				int x=to[i][j],y=to[i][k];
				if(x>y) swap(x,y);
				ed[x][y].push_back(id[i][j]*m+id[i][k]);
			}
			double W1=E1,W2=E2;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(ed[i][j].size()>=2){
				int a=ed[i][j][0]/m,b=ed[i][j][0]%m;
				int c=ed[i][j][1]/m,d=ed[i][j][1]%m;
				for(int t=0;t<T;t++){
					int v=res[t][a]^res[t][b]^res[t][c]^res[t][d];
					E2--;
					if(v==1) E1+=U;
					else E1+=V;
				}
			}
	if(E1>E2) return 2;
	return 1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 41ms
memory: 28040kb

input:

15478345200793503450
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #2:

score: 5
Accepted
time: 43ms
memory: 27984kb

input:

8777328773999050296
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #3:

score: 5
Accepted
time: 42ms
memory: 27712kb

input:

8306860370301473558
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #4:

score: 5
Accepted
time: 42ms
memory: 27848kb

input:

7355535262167792602
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #5:

score: 5
Accepted
time: 41ms
memory: 28032kb

input:

5901033176077457090
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #6:

score: 5
Accepted
time: 43ms
memory: 28056kb

input:

6725216784977925179
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #7:

score: 5
Accepted
time: 41ms
memory: 28028kb

input:

15228205213107479514
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #8:

score: 5
Accepted
time: 40ms
memory: 28024kb

input:

10794704323727532585
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #9:

score: 5
Accepted
time: 43ms
memory: 28004kb

input:

1531863096801291235
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #10:

score: 5
Accepted
time: 41ms
memory: 27764kb

input:

12583269177593428071
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #11:

score: 5
Accepted
time: 41ms
memory: 27872kb

input:

17884260014537450829
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #12:

score: 5
Accepted
time: 40ms
memory: 28004kb

input:

5598933293992250528
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #13:

score: 5
Accepted
time: 41ms
memory: 27984kb

input:

15029988260575536839
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #14:

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

input:

18435900855108017468
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #15:

score: 5
Accepted
time: 44ms
memory: 27892kb

input:

4740054765891404200
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #16:

score: 5
Accepted
time: 41ms
memory: 27992kb

input:

14854659461851577578
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #17:

score: 5
Accepted
time: 40ms
memory: 27872kb

input:

11860421814773748892
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #18:

score: 5
Accepted
time: 40ms
memory: 28048kb

input:

2618043996784533224
1237460 18364524
21312413

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #19:

score: 5
Accepted
time: 44ms
memory: 28008kb

input:

4729099511370153840
1237460 18364524
21312414

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #20:

score: 5
Accepted
time: 41ms
memory: 27876kb

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: 100ms
memory: 28176kb

input:

15644456504653888385
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #22:

score: 15
Accepted
time: 101ms
memory: 28364kb

input:

17525409403797767860
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #23:

score: 15
Accepted
time: 103ms
memory: 28292kb

input:

16953002163903257386
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #24:

score: 15
Accepted
time: 104ms
memory: 28332kb

input:

788278265436010907
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #25:

score: 15
Accepted
time: 101ms
memory: 28304kb

input:

15540481379750277983
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #26:

score: 15
Accepted
time: 100ms
memory: 28292kb

input:

9015247799051510708
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #27:

score: 15
Accepted
time: 103ms
memory: 28368kb

input:

14718463813137865720
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #28:

score: 15
Accepted
time: 44ms
memory: 27944kb

input:

9626039215908894536
1237461 18364524
21312415 32673239

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #29:

score: 15
Accepted
time: 44ms
memory: 28028kb

input:

15367994199069034681
1237461 18364524
21312414 32673236

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #30:

score: 15
Accepted
time: 104ms
memory: 28232kb

input:

9815994743565449906
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #31:

score: 15
Accepted
time: 105ms
memory: 28336kb

input:

5076972403022378194
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #32:

score: 15
Accepted
time: 103ms
memory: 28176kb

input:

13523311479884920883
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #33:

score: 15
Accepted
time: 101ms
memory: 28288kb

input:

15452059373617333584
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #34:

score: 15
Accepted
time: 102ms
memory: 28216kb

input:

8631381148034308695
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #35:

score: 15
Accepted
time: 112ms
memory: 28372kb

input:

5422315179829169150
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #36:

score: 15
Accepted
time: 106ms
memory: 28020kb

input:

4361249126136426961
1237461 18364524
21312413 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #37:

score: 15
Accepted
time: 106ms
memory: 28296kb

input:

6976800422460576686
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #38:

score: 15
Accepted
time: 100ms
memory: 28260kb

input:

8552184079474065172
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #39:

score: 15
Accepted
time: 101ms
memory: 28200kb

input:

1598183902825082255
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #40:

score: 15
Accepted
time: 102ms
memory: 28404kb

input:

3317147437384062467
1237461 18364524
21312414 32673238

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Subtask #3:

score: 18.1128
Acceptable Answer

Test #41:

score: 30
Accepted
time: 110ms
memory: 32812kb

input:

18096446825184275106
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #42:

score: 30
Accepted
time: 81ms
memory: 30084kb

input:

14902425508262229602
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #43:

score: 18.1128
Acceptable Answer
time: 113ms
memory: 33156kb

input:

15139748546799860644
1237458 18364525

output:

126534124

result:

points 0.6037593748 Correct Answer. Correct in 97 tests.

Test #44:

score: 22.5
Acceptable Answer
time: 127ms
memory: 33604kb

input:

9307674455823252809
1237458 18364525

output:

126534125

result:

points 0.75 Correct Answer. Correct in 98 tests.

Test #45:

score: 22.5
Acceptable Answer
time: 121ms
memory: 33212kb

input:

3661511870465233329
1237458 18364525

output:

126534125

result:

points 0.75 Correct Answer. Correct in 98 tests.

Test #46:

score: 30
Accepted
time: 108ms
memory: 32784kb

input:

9635149641212141231
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #47:

score: 22.5
Acceptable Answer
time: 109ms
memory: 32672kb

input:

8623126583531512280
1237458 18364525

output:

126534125

result:

points 0.75 Correct Answer. Correct in 98 tests.

Test #48:

score: 30
Accepted
time: 111ms
memory: 32868kb

input:

17542991876646715766
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #49:

score: 30
Accepted
time: 99ms
memory: 32648kb

input:

11509469256784773735
1237458 18364525

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #50:

score: 22.5
Acceptable Answer
time: 103ms
memory: 32392kb

input:

15187255126140633228
1237458 18364525

output:

126534125

result:

points 0.75 Correct Answer. Correct in 98 tests.

Test #51:

score: 30
Accepted
time: 83ms
memory: 30076kb

input:

5596351031354288494
1237458 18364525

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #52:

score: 22.5
Acceptable Answer
time: 100ms
memory: 31804kb

input:

1956884572310497827
1237458 18364525

output:

126534125

result:

points 0.75 Correct Answer. Correct in 98 tests.

Test #53:

score: 30
Accepted
time: 122ms
memory: 33596kb

input:

1848311009363078904
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #54:

score: 30
Accepted
time: 92ms
memory: 32352kb

input:

7958126186516090968
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #55:

score: 22.5
Acceptable Answer
time: 116ms
memory: 33772kb

input:

14895520484903877251
1237458 18364525

output:

126534125

result:

points 0.75 Correct Answer. Correct in 98 tests.

Test #56:

score: 30
Accepted
time: 119ms
memory: 34148kb

input:

252125976313631579
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #57:

score: 18.1128
Acceptable Answer
time: 137ms
memory: 35992kb

input:

8822075999373790379
1237458 18364525

output:

126534124

result:

points 0.6037593748 Correct Answer. Correct in 97 tests.

Test #58:

score: 30
Accepted
time: 80ms
memory: 31900kb

input:

12301960690081072082
1237458 18364525

output:

126534127

result:

ok Perfect. Correct in 100 tests.

Test #59:

score: 30
Accepted
time: 87ms
memory: 31876kb

input:

6580770166803301984
1237458 18364525

output:

126534126

result:

ok Perfect. Correct in 99 tests.

Test #60:

score: 18.1128
Acceptable Answer
time: 122ms
memory: 33728kb

input:

11293302044901951261
1237458 18364525

output:

126534124

result:

points 0.6037593748 Correct Answer. Correct in 97 tests.

Subtask #4:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 409ms
memory: 43528kb

input:

6934415118162240981
1237458 18364524
21312414 32673238 236176120

output:

126534132

result:

points 0.0 Correct Answer. Correct in 73 tests.