QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#604159 | #9380. Match | starfilter | AC ✓ | 168ms | 4124kb | C++14 | 2.0kb | 2024-10-02 00:10:10 | 2024-10-02 00:10:10 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=205,mod=998244353;
int n,op;
ll m;
ll a[N],b[N];
int C[N][N],fac[N];
bool cmp(ll x,ll y)
{
return ((x>>op)&1)<((y>>op)&1);
}
void init()
{
fac[0]=1;
for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
for(int i=0;i<=n;i++)
{
C[i][0]=C[i][i]=1;
for(int j=1;j<i;j++)
C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
}
}
vector<int> sol(int x,int y,int z,int w,int p)
{
vector<int> ans(1),f,g;
ans[0]=1;
if(x>y||z>w)return ans;
if(p<0)
{
ans.resize(min(y-x+1,w-z+1)+1);
ans[0]=1;
int k0=ans.size()-1,k1=y-x+1,k2=w-z+1;
for(int c=1;c<=k0;c++)ans[c]=(ans[c]+1ll*C[k1][c]*C[k2][c]%mod*fac[c])%mod;
return ans;
}
int m1=y+1,m2=w+1;
op=p;
sort(a+x,a+y+1,cmp);
sort(b+z,b+w+1,cmp);
for(int i=y;i>=x;i--)if((a[i]>>p)&1)m1=i;
for(int i=w;i>=z;i--)if((b[i]>>p)&1)m2=i;
ans.resize(min(y-x+1,w-z+1)+1);ans[0]=1;
if((m>>p)&1)
{
f=sol(x,m1-1,m2,w,p-1);
g=sol(m1,y,z,m2-1,p-1);
int k0=ans.size()-1,k1=f.size()-1,k2=g.size()-1;
for(int c=1;c<=k0;c++)
{
for(int i=0;i<=min(k1,c);i++)
{
if(c-i<=k2)ans[c]=(ans[c]+1ll*f[i]*g[c-i])%mod;
}
}
}
else
{
f=sol(x,m1-1,z,m2-1,p-1);
g=sol(m1,y,m2,w,p-1);
int k0=ans.size()-1,k1=f.size()-1,k2=g.size()-1;
for(int c=1;c<=k0;c++)
{
for(int i=0;i<=min(k1,c);i++)
{
for(int j=0;j<=min(k2,c)&&i+j<=c;j++)
{
int a0=m1-x-i,b0=m2-z-i;
int a1=y-m1+1-j,b1=w-m2+1-j;
int res=c-i-j;
if(min({a0,a1,b0,b1})<0)continue;
for(int k=0;k<=min({a0,b1,res});k++)
{
if(res-k>min(a1,b0))continue;
int t=1ll*C[a0][k]*C[b1][k]%mod*fac[k]%mod*C[a1][res-k]%mod*C[b0][res-k]%mod*fac[res-k]%mod;
ans[c]=(ans[c]+1ll*f[i]*g[j]%mod*t)%mod;
}
}
}
}
}
return ans;
}
int main()
{
scanf("%d %lld",&n,&m);init();
for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
vector<int> ans=sol(1,n,1,n,60);
for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
input:
9 5 1 7 2 8 4 9 2 5 10 1 3 2 4 5 8 8 8 9
output:
51 1034 10768 62195 200965 348924 294444 97344 7200
result:
ok 9 lines
Test #2:
score: 0
Accepted
time: 168ms
memory: 4124kb
input:
200 569102225177443347 1103663383682482176 1103381908705771520 1099441259031822336 1098878309078401024 1089871109823660032 1080863910568919040 1074108511127863296 1071856711314178048 1069041961547071488 1068479011593650176 1067353111686807552 1062849512059437056 1049338713177325568 10448351135499550...
output:
20506 208107723 47878304 53020813 972282728 933586852 658157196 670189811 957980024 366179738 217980591 967482558 833450149 987731802 260904367 5263881 600332344 906061351 658256294 93700706 421323952 178075016 219871690 986880524 848776106 191185484 641917326 576497440 908609746 349728876 606714342...
result:
ok 200 lines
Test #3:
score: 0
Accepted
time: 11ms
memory: 3788kb
input:
200 1098723432450995412 972777519512027136 936748722493063168 864691128455135232 860187528827764736 857935729014079488 856246879153815552 855683929200394240 851180329573023744 848928529759338496 847802629852495872 847310048643252224 847239679899074560 846676729945653248 828662331436171264 8280993814...
output:
8320 34035512 428014253 916072411 696504298 748377440 32424677 188402417 233587075 130639672 759476380 546285625 187068736 159002787 131866334 381530906 133126344 373727612 923311054 725293681 718162548 39511135 322320638 44709653 156884882 285926751 787179409 282967016 153092344 615721347 950855850...
result:
ok 200 lines
Test #4:
score: 0
Accepted
time: 7ms
memory: 3896kb
input:
200 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
3072 4412928 940025853 665370743 752672705 581549490 41990996 541401698 170451802 26584141 220983766 844620126 64506869 137621326 418866920 351049174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 200 lines
Test #5:
score: 0
Accepted
time: 8ms
memory: 3904kb
input:
200 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
40000 792020000 319908096 286630939 515085548 95626140 472749362 800008042 594973486 139901984 847967250 125664877 254232250 419486325 204481923 979660340 41873095 540955890 585129047 205968776 196086667 674391130 737319172 669580034 973843015 207125612 331414909 119844754 24879477 990932807 8476927...
result:
ok 200 lines
Extra Test:
score: 0
Extra Test Passed