# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
463694 | mosiashvililuka | Fishing Game (RMI19_fishing) | C++17 | 37 ms | 12824 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,mod=1000000007LL,dp[303][303][303],tes,t,II,k,kk,f[8],bl[603];
void rec(long long q, bool bo){
if(f[1]<0||f[2]<0||f[3]<0) return;
long long ZX=zx;
if(q==4){
if(bo==0) return;
dp[i][j][k]+=dp[f[1]][f[2]][f[3]]*zx;dp[i][j][k]%=mod;
return;
}
if(q==1){
zx*=f[1];zx%=mod;
f[1]--;
rec(q+1,1);
zx=ZX;
f[1]++;
//
zx*=f[3];zx%=mod;
f[3]--;f[2]++;
rec(q+1,bo);
zx=ZX;
f[3]++;f[2]--;
return;
}
if(q==2){
zx*=f[1];zx%=mod;
f[1]--;f[3]++;
rec(q+1,bo);
zx=ZX;
f[1]++;f[3]--;
//
zx*=f[2];zx%=mod;
f[2]--;
rec(q+1,1);
zx=ZX;
f[2]++;
return;
}
if(q==3){
zx*=f[2];zx%=mod;
f[2]--;f[1]++;
rec(q+1,bo);
zx=ZX;
f[2]++;f[1]--;
//
zx*=f[3];zx%=mod;
f[3]--;
rec(q+1,1);
zx=ZX;
f[3]++;
return;
}
}
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>tes;
dp[0][0][0]=1;
for(II=1; II<=100; II++){
for(i=0; i<=II; i++){
for(j=0; j<=II-i; j++){
k=II-i-j;
f[1]=i;f[2]=j;f[3]=k;zx=1;
rec(1,0);
}
}
}
for(t=1; t<=tes; t++){
f[1]=0;f[2]=0;f[3]=0;
for(i=0; i<=a*6; i++){
bl[i]=0;
}
for(i=1; i<=3; i++){
for(j=1; j<=2*a; j++){
cin>>c;
if(bl[c]==0){
bl[c]=i;
}else{
if(bl[c]==1&&i==2){
f[1]++;
}
if(bl[c]==2&&i==3){
f[2]++;
}
if(bl[c]==1&&i==3){
f[3]++;
}
}
}
}
cout<<dp[f[1]][f[2]][f[3]]<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |