Submission #361590

#TimeUsernameProblemLanguageResultExecution timeMemory
361590iliccmarkoFishing Game (RMI19_fishing)C++14
0 / 100
178 ms215076 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define INF 1000000000 #define LINF 1000000000000000LL #define pb push_back #define all(x) x.begin(), x.end() #define len(s) (int)s.size() #define test_case { int t; cin>>t; while(t--)solve(); } #define single_case solve(); #define line cerr<<"----------"<<endl; #define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); } #define mod 1000000007LL const int N = 305; ll dp[N][N][N]; ll a[N], b[N], c[N]; ll resi(ll x, ll y, ll z) { //cout<<x<<" "<<y<<" "<<z<<endl; if(x<0||y<0||z<0) return 0; if(dp[x][y][z]!=-1) return dp[x][y][z]; dp[x][y][z] = (z*x*z*resi(x-1, y+1, z-1))%mod; dp[x][y][z] = (dp[x][y][z] + z*(y+1)*y*resi(x+1, y-1, z-1))%mod; dp[x][y][z] = (dp[x][y][z] + x*(x-1)*y*resi(x-1, y-1, z+1))%mod; dp[x][y][z] = (dp[x][y][z] + x*y*(y-1)*resi(x, y-2, z))%mod; dp[x][y][z] = (dp[x][y][z] + x*(x-1)*z*resi(x-2, y, z))%mod; dp[x][y][z] = (dp[x][y][z] + z*(y+1)*(z-1)*resi(x, y, z-2))%mod; dp[x][y][z] = (dp[x][y][z] + x*y*z*resi(x-1, y-1, z-1))%mod; return dp[x][y][z]; } int main() { ios ll n, t; cin>>n>>t; for(int i = 0;i<3*n+2;i++)for(int j = 0;j<3*n+2;j++)for(int z = 0;z<3*n+2;z++) dp[i][j][z] = -1; dp[0][0][0] = 1; while(t--) { //for(int i = 0;i<3*n+2;i++)for(int j = 0;j<3*n+2;j++)for(int z = 0;z<3*n+2;z++) dp[i][j][z] = -1; for(int i = 0;i<N;i++) a[i] = b[i] = c[i] = 0; for(int i = 0;i<2*n;i++) { ll x; cin>>x; a[x]++; } for(int i = 0;i<2*n;i++) { ll x; cin>>x; b[x]++; } for(int i = 0;i<2*n;i++) { ll x; cin>>x; c[x]++; } ll x, y, z; x = y = z = 0; for(int i = 1;i<=3*n;i++) if(a[i]&&b[i]) x++; for(int i = 1;i<=3*n;i++) if(b[i]&&c[i]) y++; for(int i = 1;i<=3*n;i++) if(a[i]&&c[i]) z++; cout<<resi(x, y, z)<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...