QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#20582 | #2492. Hash Function | _silhouette_ | WA | 2095ms | 10324kb | C++14 | 2.0kb | 2022-02-16 18:11:42 | 2022-05-03 10:39:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int Max_N=16,Mod=114514;
int n,H,N,M,Num,lin[Mod+5];
unsigned int A[Max_N<<1],B[Max_N<<1],R[Max_N<<1],C[Max_N<<1],a1[1<<19],a2[1<<7],a3[1<<7],c1[1<<19],c2[1<<7],c3[1<<7];
vector<int> S1,S2,S3;
struct Edge{ int Next,val1,val2; } e[1<<26];
void Add(int x,int val){
int h=x%Mod;
for(int i=lin[h];i;i=e[i].Next)
if(e[i].val1==x) return;
e[++Num].Next=lin[h]; lin[h]=Num; e[Num].val1=x; e[Num].val2=val;
}
int Ask(int x){
int h=x%Mod;
for(int i=lin[h];i;i=e[i].Next)
if(e[i].val1==x) return e[i].val2;
return -1;
}
int main(){
scanf("%d%d",&n,&H);
N=n<<1; M=(1<<N-1)-1;
unsigned int e=1;
for(int i=0;i<N;i++)
if(i<n) B[i]=(e<<i)^(e<<(2*i+1));
else B[i]=(e<<i)^(e<<(4*n-2*i-2));
for(int i=0;i<N;i++) R[i]=B[(i+1)%N];
for(int i=0;i<N;i++) C[i]=B[i]^R[i];
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
if((C[j]>>i)&1) A[i]|=1<<j;
for(int i=0;i<N;i++){
int Min=N-1,Max=0;
for(int j=0;j<N;j++)
if((1<<j)&A[i])
Min=min(Min,j),
Max=max(Max,j);
if(Max<n) S2.push_back(i);
else if(Min>=n) S3.push_back(i);
else S1.push_back(i);
}
for(int i=0;i<1<<S1.size();i++){
for(int j=0;j<S1.size();j++)
if((1<<j)&i) a1[i]^=e<<S1[j],c1[i]^=A[S1[j]];
}
for(int i=0;i<1<<S2.size();i++){
for(int j=0;j<S2.size();j++)
if((1<<j)&i) a2[i]^=e<<S2[j],c2[i]^=A[S2[j]];
}
for(int i=0;i<1<<S3.size();i++){
for(int j=0;j<S3.size();j++)
if((1<<j)&i) a3[i]^=e<<S3[j],c3[i]^=A[S3[j]];
}
int s=(e<<N)-(e<<n);
for(int i=0;i<1<<S1.size();i++){
for(int j=0;j<1<<S2.size();j++){
int val=(239ll*a2[j]+153ll*((c1[i]^c2[j])&((e<<n)-1)))%M;
Add(val,a2[j]);
}
for(int j=0;j<1<<S3.size();j++){
int val=(H-(239ll*(a1[i]+a3[j])+153ll*((c1[i]^c3[j])&((e<<N)-(e<<n))))%M+M)%M;
int ans=Ask(val);
if(ans!=-1){ printf("%u\n",ans^a1[i]^a3[j]); return 0; }
}
Num=0;
for(int j=0;j<1<<S2.size();j++)
lin[(239ll*a2[j]+153ll*((c1[i]^c2[j])&((e<<n)-1)))%M%Mod]=0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7956kb
input:
4 83
output:
13
result:
ok good solution
Test #2:
score: 0
Accepted
time: 2ms
memory: 8400kb
input:
10 497091
output:
153014
result:
ok good solution
Test #3:
score: 0
Accepted
time: 4ms
memory: 7796kb
input:
4 55
output:
73
result:
ok good solution
Test #4:
score: 0
Accepted
time: 264ms
memory: 8508kb
input:
15 444650548
output:
377677832
result:
ok good solution
Test #5:
score: 0
Accepted
time: 163ms
memory: 8364kb
input:
14 114355996
output:
119238393
result:
ok good solution
Test #6:
score: 0
Accepted
time: 37ms
memory: 8636kb
input:
16 0
output:
0
result:
ok good solution
Test #7:
score: 0
Accepted
time: 1ms
memory: 9908kb
input:
3 22
output:
8
result:
ok good solution
Test #8:
score: 0
Accepted
time: 6ms
memory: 9928kb
input:
8 8319
output:
15407
result:
ok good solution
Test #9:
score: 0
Accepted
time: 31ms
memory: 8272kb
input:
12 7629490
output:
11766463
result:
ok good solution
Test #10:
score: 0
Accepted
time: 5ms
memory: 7792kb
input:
2 2
output:
3
result:
ok good solution
Test #11:
score: 0
Accepted
time: 38ms
memory: 9672kb
input:
16 0
output:
0
result:
ok good solution
Test #12:
score: 0
Accepted
time: 31ms
memory: 10052kb
input:
16 0
output:
0
result:
ok good solution
Test #13:
score: 0
Accepted
time: 38ms
memory: 9340kb
input:
16 0
output:
0
result:
ok good solution
Test #14:
score: 0
Accepted
time: 4ms
memory: 8400kb
input:
11 1086647
output:
1875946
result:
ok good solution
Test #15:
score: 0
Accepted
time: 7ms
memory: 8264kb
input:
11 188671
output:
393405
result:
ok good solution
Test #16:
score: 0
Accepted
time: 7ms
memory: 8340kb
input:
11 2028522
output:
424106
result:
ok good solution
Test #17:
score: 0
Accepted
time: 60ms
memory: 10180kb
input:
13 23601796
output:
40518521
result:
ok good solution
Test #18:
score: 0
Accepted
time: 0ms
memory: 7992kb
input:
8 29405
output:
7325
result:
ok good solution
Test #19:
score: 0
Accepted
time: 6ms
memory: 7848kb
input:
7 2218
output:
3174
result:
ok good solution
Test #20:
score: 0
Accepted
time: 4ms
memory: 7780kb
input:
7 432
output:
662
result:
ok good solution
Test #21:
score: 0
Accepted
time: 8ms
memory: 10324kb
input:
11 899191
output:
570326
result:
ok good solution
Test #22:
score: 0
Accepted
time: 4ms
memory: 7960kb
input:
5 494
output:
281
result:
ok good solution
Test #23:
score: 0
Accepted
time: 3ms
memory: 9932kb
input:
8 13862
output:
12212
result:
ok good solution
Test #24:
score: 0
Accepted
time: 5ms
memory: 8284kb
input:
11 899027
output:
1622100
result:
ok good solution
Test #25:
score: 0
Accepted
time: 5ms
memory: 8020kb
input:
8 7446
output:
49853
result:
ok good solution
Test #26:
score: 0
Accepted
time: 2ms
memory: 7868kb
input:
3 12
output:
6
result:
ok good solution
Test #27:
score: 0
Accepted
time: 2ms
memory: 7920kb
input:
8 6258
output:
18666
result:
ok good solution
Test #28:
score: 0
Accepted
time: 315ms
memory: 8340kb
input:
15 191474555
output:
411455767
result:
ok good solution
Test #29:
score: 0
Accepted
time: 4ms
memory: 7892kb
input:
3 17
output:
20
result:
ok good solution
Test #30:
score: 0
Accepted
time: 285ms
memory: 8640kb
input:
15 161474861
output:
318717104
result:
ok good solution
Test #31:
score: 0
Accepted
time: 1ms
memory: 8316kb
input:
10 180816
output:
81147
result:
ok good solution
Test #32:
score: 0
Accepted
time: 2ms
memory: 7796kb
input:
4 116
output:
81
result:
ok good solution
Test #33:
score: -100
Wrong Answer
time: 2095ms
memory: 9660kb
input:
16 1196684556
output:
result:
wrong output format Unexpected end of file - int64 expected