#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+1)*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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
2924 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
9708 KB |
Output isn't correct |
5 |
Incorrect |
37 ms |
56044 KB |
Output isn't correct |
6 |
Incorrect |
56 ms |
80128 KB |
Output isn't correct |
7 |
Incorrect |
79 ms |
108396 KB |
Output isn't correct |
8 |
Incorrect |
107 ms |
141036 KB |
Output isn't correct |
9 |
Incorrect |
140 ms |
178156 KB |
Output isn't correct |
10 |
Incorrect |
171 ms |
215020 KB |
Output isn't correct |