QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#868106 | #9689. 伪伪随机 | lgvc# | 20 | 82ms | 4864kb | C++23 | 2.5kb | 2025-01-24 12:26:52 | 2025-01-24 12:26:52 |
Judging History
answer
#include "prg.h"
#include <bits/stdc++.h>
int pa[3009],cl[3009],sz[3009],hd[1009],to[6009],nxt[6009],val[6009],kk;
void l(int u,int v,int w) {
to[++kk]=v;nxt[kk]=hd[u];val[kk]=w;hd[u]=kk;
}
inline int fr(int x) {
while(x!=pa[x]) {
x=pa[x];
}
return pa[x];
}
inline int qq(int x) {
int as=0;
while(x!=pa[x]) {
as^=cl[x];
x=pa[x];
}
return as;
}
int chk(int x,int y,int va) {
int aa=fr(x);
int bb=fr(y);
if(aa==bb) {
if((qq(x)^qq(y))==va) return 1;
return 0;
}
if(sz[aa]>sz[bb]) std::swap(aa,bb);
sz[bb]+=sz[aa];
cl[aa]=(va^qq(x)^qq(y));
pa[aa]=bb;
return 1;
}
std::array<std::vector<int>, 3000> xt;
int K;
bool cmp(int a,int b) {
return std::max(xt[a][K-1],xt[a][K-2])<std::max(xt[b][K-1],xt[b][K-2]);
}
int solve(int n, int m, int k, std::vector<int> op, std::array<std::vector<int>, 3000> x,
int c, std::array<std::array<int, 3000>, 25> s) {
K=k;xt=x;
int as=0;
for(int i=1;i<=25;i++) {
for(int j=1;j<=3000;j++) {
if(s[i-1][j-1]==1) as++;
}
}
if(op[k-2]!=2) {
if(as>=35000&&as<=40000) return 1;
return 2;
}
if(op[k-3]!=2) {
int vv=0;
std::vector<int> t[1009];
for(int j=1;j<=25;j++) {
int as=0;
for(int i=0;i<=1000;i++) t[i]=t[1001];
for(int i=1;i<=3000;i++) {
t[x[i-1][k-1]].push_back(i);
if(s[j-1][i-1]==1) as++;
}
for(int i=0;i<=1000;i++) {
int as=0;
for(int jj=0;jj<t[i].size();jj++) {
as+=s[j-1][t[i][jj]-1];
}
vv+=std::min(as,(signed)t[i].size()-as);
}
}
// printf("%d\n",vv);
if(vv<=20000||vv>=55000) return 2;
return 1;
}
int p[3009],c1=0,c2=0,vi[1009]={0},v2[1009]={0},tt=0;
std::mt19937 rng(114);
for(int i=0;i<25;i++) {
for(int j=0;j<1000;j++) hd[j]=0;
kk=0;
for(int j=0;j<3000;j++) {
int p1=x[j][k-1],p2=x[j][k-2];
l(p1,p2,(s[i][j]^op[0]));
l(p2,p1,(s[i][j]^op[0]));
}
for(int i=0;i<1000;i++) {
tt++;
for(int j=hd[i];j;j=nxt[j]) {
vi[to[j]]=tt;
v2[to[j]]=val[j];
}
for(int j=hd[i];j;j=nxt[j]) {
for(int k=hd[to[j]];k;k=nxt[k]) {
if(vi[to[k]]==tt) {
if((val[j]^val[k]^v2[to[k]])==0) c1++;
else c2++;
}
}
}
}
}
long double g1=1;
int xx=std::min(c1,c2);
printf("%d %d\n",c1,c2);
while(c1||c2) {
if(c1==0) {
c2--;
g1=g1*7/8;
} else if(c2==0) {
c1--;
g1=g1*9/8;
} else if(g1>1) {
c2--;
g1=g1*7/8;
} else {
c1--;
g1=g1*9/8;
}
}
// if(g1>=0.99) printf("2\n");
// else printf("1\n");
// printf("%d %d\n",c1,c2);
if(g1>=1) 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: 38ms
memory: 4736kb
input:
15478345200793503450 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #2:
score: 5
Accepted
time: 37ms
memory: 4736kb
input:
8777328773999050296 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #3:
score: 5
Accepted
time: 35ms
memory: 4736kb
input:
8306860370301473558 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #4:
score: 5
Accepted
time: 36ms
memory: 4736kb
input:
7355535262167792602 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #5:
score: 5
Accepted
time: 36ms
memory: 4736kb
input:
5901033176077457090 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #6:
score: 5
Accepted
time: 37ms
memory: 4736kb
input:
6725216784977925179 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #7:
score: 5
Accepted
time: 36ms
memory: 4736kb
input:
15228205213107479514 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #8:
score: 5
Accepted
time: 37ms
memory: 4864kb
input:
10794704323727532585 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #9:
score: 5
Accepted
time: 37ms
memory: 4608kb
input:
1531863096801291235 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #10:
score: 5
Accepted
time: 36ms
memory: 4736kb
input:
12583269177593428071 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #11:
score: 5
Accepted
time: 35ms
memory: 4736kb
input:
17884260014537450829 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #12:
score: 5
Accepted
time: 35ms
memory: 4736kb
input:
5598933293992250528 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #13:
score: 5
Accepted
time: 35ms
memory: 4736kb
input:
15029988260575536839 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #14:
score: 5
Accepted
time: 35ms
memory: 4480kb
input:
18435900855108017468 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #15:
score: 5
Accepted
time: 37ms
memory: 4736kb
input:
4740054765891404200 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #16:
score: 5
Accepted
time: 34ms
memory: 4736kb
input:
14854659461851577578 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #17:
score: 5
Accepted
time: 35ms
memory: 4736kb
input:
11860421814773748892 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #18:
score: 5
Accepted
time: 36ms
memory: 4608kb
input:
2618043996784533224 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #19:
score: 5
Accepted
time: 37ms
memory: 4736kb
input:
4729099511370153840 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #20:
score: 5
Accepted
time: 38ms
memory: 4736kb
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: 80ms
memory: 4736kb
input:
15644456504653888385 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #22:
score: 15
Accepted
time: 80ms
memory: 4736kb
input:
17525409403797767860 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #23:
score: 15
Accepted
time: 81ms
memory: 4736kb
input:
16953002163903257386 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #24:
score: 15
Accepted
time: 79ms
memory: 4736kb
input:
788278265436010907 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #25:
score: 15
Accepted
time: 80ms
memory: 4736kb
input:
15540481379750277983 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #26:
score: 15
Accepted
time: 80ms
memory: 4736kb
input:
9015247799051510708 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #27:
score: 15
Accepted
time: 81ms
memory: 4736kb
input:
14718463813137865720 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #28:
score: 15
Accepted
time: 41ms
memory: 4736kb
input:
9626039215908894536 1237461 18364524 21312415 32673239
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #29:
score: 15
Accepted
time: 40ms
memory: 4736kb
input:
15367994199069034681 1237461 18364524 21312414 32673236
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #30:
score: 15
Accepted
time: 81ms
memory: 4736kb
input:
9815994743565449906 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #31:
score: 15
Accepted
time: 82ms
memory: 4736kb
input:
5076972403022378194 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #32:
score: 15
Accepted
time: 80ms
memory: 4736kb
input:
13523311479884920883 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #33:
score: 15
Accepted
time: 81ms
memory: 4736kb
input:
15452059373617333584 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #34:
score: 15
Accepted
time: 81ms
memory: 4736kb
input:
8631381148034308695 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #35:
score: 15
Accepted
time: 82ms
memory: 4608kb
input:
5422315179829169150 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #36:
score: 15
Accepted
time: 79ms
memory: 4736kb
input:
4361249126136426961 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #37:
score: 15
Accepted
time: 79ms
memory: 4736kb
input:
6976800422460576686 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #38:
score: 15
Accepted
time: 81ms
memory: 4736kb
input:
8552184079474065172 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #39:
score: 15
Accepted
time: 79ms
memory: 4736kb
input:
1598183902825082255 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #40:
score: 15
Accepted
time: 79ms
memory: 4736kb
input:
3317147437384062467 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Subtask #3:
score: 0
Checker Runtime Error
Test #41:
score: 0
Checker Runtime Error
input:
18096446825184275106 1237458 18364525
output:
2610 2640 2718 2832 2698 2502 2462 2288 2640 2610 3402 2598 2472 2328 1902 1398 126534127
result:
Subtask #4:
score: 0
Checker Runtime Error
Test #61:
score: 0
Checker Runtime Error
input:
6934415118162240981 1237458 18364524 21312414 32673238 236176120
output:
3456 2694 2898 1902 2934 2466 3264 2286 3204 2346 2292 2358 3450 2700 2598 2652 2382 2118 2676 2124 3372 3078 2688 2712 3222 2778 3192 3358 2064 2136 2794 2856 1512 1638 2250 2400 2742 2208 2946 2604 2424 2226 3792 2658 2736 2214 3354 2496 2454 2346 2112 1638 3654 2896 2838 2262 2916 2334 4054 3996 ...