QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#885088 | #9689. 伪伪随机 | 275307894a | 80.187969 | 2828ms | 5120kb | C++20 | 3.5kb | 2025-02-06 13:34:34 | 2025-02-06 13:34:39 |
Judging History
answer
#include "prg.h"
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e3+5,M=2e5+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=2e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int qry(int x,int y,int op){
if(op==0) return x&y;
if(op==1) return x|y;
return x^y;
}
pii calc(vector<int> op){
int c0=0,c1=0;
int k=op.size()+1;
for(int i=0;i<(1<<k);i++){
int w=i&1;
for(int j=1;j<k;j++) w=qry(w,i>>j&1,op[j-1]);
(w?c1:c0)++;
}
return make_pair(c0,c1);
}
int solve(int n,int m,int k,vector<int> op,array<vector<int>,3000> x,int c,array<array<int,3000>,25> s){
db p=-log(1.0/2)*m*c;
auto [t0,t1]=calc(op);
if(t0^t1){
for(int i=0;i<c;i++){
for(int j=0;j<m;j++){
p+=log((s[i][j]?t1:t0)*1.0/(t0+t1));
}
}
}else{
op.pop_back();
auto [t0,t1]=calc(op);
// gdb(t0,t1);
if(t0^t1){
for(int i=0;i<c;i++){
static int cnt[N][2];
Me(cnt,0);
for(int j=0;j<m;j++) cnt[x[j].back()][s[i][j]]++;
for(int j=0;j<n;j++){
db w=pow(t0*1.0/(t0+t1),cnt[j][0])*pow(t1*1.0/(t0+t1),cnt[j][1]);
w+=pow(t0*1.0/(t0+t1),cnt[j][1])*pow(t1*1.0/(t0+t1),cnt[j][0]);
p+=log(w*0.5);
}
}
}else{
op.pop_back();
if(op[0]==1){
for(int i=0;i<c;i++) for(int j=0;j<m;j++) s[i][j]^=1;
}
static vector<tuple<int,int,int> > S[N];
p=0;
int cts=0;
for(int i=0;i<c;i++){
for(int j=0;j<n;j++) S[j].clear();
for(int j=0;j<m;j++){
int a=x[j][2],b=x[j][3];
S[a].emplace_back(b,s[i][j],j);
S[b].emplace_back(a,s[i][j],j);
}
for(int j=0;j<n;j++){
sort(all(S[j]));
reverse(all(S[j]));
}
for(int j=0;j<n;j++){
for(auto [a1,b1,c1]:S[j]){
if(a1<j) break;
for(auto [a2,b2,c2]:S[a1]) if(c2^c1){
if(a2<j) break;
if(a2==j) p+=log((b1^b2?6:10)/16.0)-log(1/2.0);
for(auto [a3,b3,c3]:S[a2]) if(c3^c1&&c3^c2){
if(a3<a1) break;
if(a3==j) p+=log((b1^b2^b3?28:36)/64.0)-log(1/2.0);
for(auto [a4,b4,c4]:S[a3]) if(c4^c3&&c4^c2&&c4^c1){
if(a4<j) break;
if(a4==j) p+=log((b1^b2^b3^b4?120:136)/256.0)-log(1/2.0);
cts++;
}
}
}
}
}
}
gdb(cts);
/*auto [t0,t1]=calc(op);
gdb(t0,t1);
for(int i=0;i<c;i++){
map<pii,array<int,2> > f;
for(int j=0;j<m;j++){
int a=x[j][2],b=x[j][3];
if(a>b) swap(a,b);
f[make_pair(a,b)][s[i][j]]++;
}
for(auto [a,b]:f){
db w=pow(t0*1.0/(t0+t1),b[0])*pow(t1*1.0/(t0+t1),b[1]);
w+=pow(t0*1.0/(t0+t1),b[1])*pow(t1*1.0/(t0+t1),b[0]);
p+=log(w*0.5);
}
}*/
}
}
return p>0?2:1;
}
// i=prg;g++ -o $i grader.cpp $i.cpp -std=c++17 -DLOCAL -O2&& ./$i < 1.in
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 81ms
memory: 4608kb
input:
15478345200793503450 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #2:
score: 5
Accepted
time: 81ms
memory: 4608kb
input:
8777328773999050296 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #3:
score: 5
Accepted
time: 81ms
memory: 4736kb
input:
8306860370301473558 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #4:
score: 5
Accepted
time: 84ms
memory: 4736kb
input:
7355535262167792602 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #5:
score: 5
Accepted
time: 81ms
memory: 4608kb
input:
5901033176077457090 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #6:
score: 5
Accepted
time: 79ms
memory: 4736kb
input:
6725216784977925179 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #7:
score: 5
Accepted
time: 80ms
memory: 4608kb
input:
15228205213107479514 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #8:
score: 5
Accepted
time: 81ms
memory: 4608kb
input:
10794704323727532585 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #9:
score: 5
Accepted
time: 80ms
memory: 4608kb
input:
1531863096801291235 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #10:
score: 5
Accepted
time: 82ms
memory: 4736kb
input:
12583269177593428071 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #11:
score: 5
Accepted
time: 82ms
memory: 4736kb
input:
17884260014537450829 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #12:
score: 5
Accepted
time: 81ms
memory: 4608kb
input:
5598933293992250528 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #13:
score: 5
Accepted
time: 81ms
memory: 4736kb
input:
15029988260575536839 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #14:
score: 5
Accepted
time: 80ms
memory: 4608kb
input:
18435900855108017468 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #15:
score: 5
Accepted
time: 79ms
memory: 4736kb
input:
4740054765891404200 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #16:
score: 5
Accepted
time: 81ms
memory: 4608kb
input:
14854659461851577578 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #17:
score: 5
Accepted
time: 81ms
memory: 4736kb
input:
11860421814773748892 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #18:
score: 5
Accepted
time: 80ms
memory: 4736kb
input:
2618043996784533224 1237460 18364524 21312413
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #19:
score: 5
Accepted
time: 82ms
memory: 4608kb
input:
4729099511370153840 1237460 18364524 21312414
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #20:
score: 5
Accepted
time: 81ms
memory: 4608kb
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: 212ms
memory: 4608kb
input:
15644456504653888385 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #22:
score: 15
Accepted
time: 211ms
memory: 4608kb
input:
17525409403797767860 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #23:
score: 15
Accepted
time: 213ms
memory: 4736kb
input:
16953002163903257386 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #24:
score: 15
Accepted
time: 210ms
memory: 4736kb
input:
788278265436010907 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #25:
score: 15
Accepted
time: 212ms
memory: 4736kb
input:
15540481379750277983 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #26:
score: 15
Accepted
time: 212ms
memory: 4736kb
input:
9015247799051510708 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #27:
score: 15
Accepted
time: 212ms
memory: 4736kb
input:
14718463813137865720 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #28:
score: 15
Accepted
time: 87ms
memory: 4736kb
input:
9626039215908894536 1237461 18364524 21312415 32673239
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #29:
score: 15
Accepted
time: 99ms
memory: 4608kb
input:
15367994199069034681 1237461 18364524 21312414 32673236
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #30:
score: 15
Accepted
time: 213ms
memory: 4736kb
input:
9815994743565449906 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #31:
score: 15
Accepted
time: 213ms
memory: 4736kb
input:
5076972403022378194 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #32:
score: 15
Accepted
time: 214ms
memory: 4736kb
input:
13523311479884920883 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #33:
score: 15
Accepted
time: 210ms
memory: 4736kb
input:
15452059373617333584 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #34:
score: 15
Accepted
time: 216ms
memory: 4736kb
input:
8631381148034308695 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #35:
score: 15
Accepted
time: 213ms
memory: 4736kb
input:
5422315179829169150 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #36:
score: 15
Accepted
time: 209ms
memory: 4608kb
input:
4361249126136426961 1237461 18364524 21312413 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #37:
score: 15
Accepted
time: 213ms
memory: 4736kb
input:
6976800422460576686 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #38:
score: 15
Accepted
time: 211ms
memory: 4736kb
input:
8552184079474065172 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #39:
score: 15
Accepted
time: 211ms
memory: 4736kb
input:
1598183902825082255 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #40:
score: 15
Accepted
time: 212ms
memory: 4608kb
input:
3317147437384062467 1237461 18364524 21312414 32673238
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Subtask #3:
score: 30
Accepted
Test #41:
score: 30
Accepted
time: 323ms
memory: 4992kb
input:
18096446825184275106 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #42:
score: 30
Accepted
time: 196ms
memory: 4992kb
input:
14902425508262229602 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #43:
score: 30
Accepted
time: 366ms
memory: 5120kb
input:
15139748546799860644 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #44:
score: 30
Accepted
time: 388ms
memory: 5120kb
input:
9307674455823252809 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #45:
score: 30
Accepted
time: 367ms
memory: 4992kb
input:
3661511870465233329 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #46:
score: 30
Accepted
time: 330ms
memory: 4864kb
input:
9635149641212141231 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #47:
score: 30
Accepted
time: 331ms
memory: 4864kb
input:
8623126583531512280 1237458 18364525
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #48:
score: 30
Accepted
time: 340ms
memory: 4992kb
input:
17542991876646715766 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #49:
score: 30
Accepted
time: 334ms
memory: 4992kb
input:
11509469256784773735 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #50:
score: 30
Accepted
time: 314ms
memory: 4992kb
input:
15187255126140633228 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #51:
score: 30
Accepted
time: 209ms
memory: 4992kb
input:
5596351031354288494 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #52:
score: 30
Accepted
time: 278ms
memory: 4864kb
input:
1956884572310497827 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #53:
score: 30
Accepted
time: 394ms
memory: 4992kb
input:
1848311009363078904 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #54:
score: 30
Accepted
time: 308ms
memory: 4992kb
input:
7958126186516090968 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #55:
score: 30
Accepted
time: 377ms
memory: 4864kb
input:
14895520484903877251 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #56:
score: 30
Accepted
time: 414ms
memory: 4992kb
input:
252125976313631579 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #57:
score: 30
Accepted
time: 541ms
memory: 4864kb
input:
8822075999373790379 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #58:
score: 30
Accepted
time: 275ms
memory: 4864kb
input:
12301960690081072082 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #59:
score: 30
Accepted
time: 284ms
memory: 4992kb
input:
6580770166803301984 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #60:
score: 30
Accepted
time: 388ms
memory: 4864kb
input:
11293302044901951261 1237458 18364525
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Subtask #4:
score: 30.188
Acceptable Answer
Test #61:
score: 50
Accepted
time: 2808ms
memory: 4864kb
input:
6934415118162240981 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #62:
score: 50
Accepted
time: 2812ms
memory: 4992kb
input:
3842633665807973417 1237458 18364524 21312413 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #63:
score: 50
Accepted
time: 2817ms
memory: 4992kb
input:
7239866286946328663 1237458 18364524 21312414 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #64:
score: 50
Accepted
time: 2810ms
memory: 4992kb
input:
7703816040948127846 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #65:
score: 50
Accepted
time: 2821ms
memory: 4992kb
input:
3603384166177697472 1237458 18364524 21312413 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #66:
score: 50
Accepted
time: 2820ms
memory: 4992kb
input:
3656923047342207392 1237458 18364524 21312414 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #67:
score: 50
Accepted
time: 2816ms
memory: 5120kb
input:
527459705711820317 1237458 18364524 21312413 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #68:
score: 37.5
Acceptable Answer
time: 2820ms
memory: 5120kb
input:
9663120536403908130 1237458 18364524 21312413 32673238 236176120
output:
126534125
result:
points 0.75 Correct Answer. Correct in 98 tests.
Test #69:
score: 50
Accepted
time: 215ms
memory: 4608kb
input:
9439840407846051020 1237458 18364524 21312414 32673236 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #70:
score: 50
Accepted
time: 2806ms
memory: 4864kb
input:
13809961864883455849 1237458 18364524 21312413 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #71:
score: 50
Accepted
time: 2809ms
memory: 4864kb
input:
15124215729371202231 1237458 18364524 21312414 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #72:
score: 50
Accepted
time: 2805ms
memory: 4992kb
input:
7117551168813448970 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #73:
score: 50
Accepted
time: 2828ms
memory: 4864kb
input:
5561290863673255532 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #74:
score: 50
Accepted
time: 2820ms
memory: 4992kb
input:
13802789789482912767 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #75:
score: 50
Accepted
time: 2816ms
memory: 5120kb
input:
9913943612955590097 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.
Test #76:
score: 30.188
Acceptable Answer
time: 2809ms
memory: 4992kb
input:
9308648462630523956 1237458 18364524 21312414 32673238 236176120
output:
126534124
result:
points 0.6037593748 Correct Answer. Correct in 97 tests.
Test #77:
score: 37.5
Acceptable Answer
time: 2808ms
memory: 4864kb
input:
7898242699188216716 1237458 18364524 21312414 32673238 236176120
output:
126534125
result:
points 0.75 Correct Answer. Correct in 98 tests.
Test #78:
score: 50
Accepted
time: 2814ms
memory: 4864kb
input:
17772607140853820910 1237458 18364524 21312414 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #79:
score: 50
Accepted
time: 2813ms
memory: 5120kb
input:
3917596392610036445 1237458 18364524 21312413 32673238 236176120
output:
126534126
result:
ok Perfect. Correct in 99 tests.
Test #80:
score: 50
Accepted
time: 2815ms
memory: 4736kb
input:
7049562837957796004 1237458 18364524 21312414 32673238 236176120
output:
126534127
result:
ok Perfect. Correct in 100 tests.