답안 #274260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
274260 2020-08-19T10:37:27 Z theStaticMind Fishing Game (RMI19_fishing) C++14
0 / 100
953 ms 214008 KB
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int dp[301][301][301];

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, q;
	cin >> n >> q;

	while(q--){
		map<int, int> A;
		map<int, int> B;
		map<int, int> C;

		for(int i = 0; i < n*2; i++){
			int x;
			cin >> x;
			A[x]++;
		}
		for(int i = 0; i < n*2; i++){
			int x;
			cin >> x;
			B[x]++;
		}
		for(int i = 0; i < n*2; i++){
			int x;
			cin >> x;
			C[x]++;
		}

		for(int i = 0; i <= 300; i++){
			for(int j = 0; j <= 300; j++){
				for(int k = 0; k <= 300; k++){
					dp[i][j][k] = 0;
				}
			}
		}

		int a = 0, b = 0, c = 0;

		for(int i = 1; i <= 3*n; i++){
			if(A[i] == 1 && B[i] == 1) a++;
			if(A[i] == 1 && C[i] == 1) b++;
			if(B[i] == 1 && C[i] == 1) c++;
		}

		dp[a][b][c] = 1;

		for(int s = a + b + c; s >= 0; s--){
			for(int i = 0; i <= 300; i++){
				for(int j = 0; j <= 300 && i + j <= s; j++){
					int k = s - i - j;

					// a-a-b
					if(i-2>=0 && j+1<=300 && k-1>=0)
					dp[i-2][j+1][k-1] = (dp[i-2][j+1][k-1] + dp[i][j][k] * i * (i - 1) * (j + 1)) % modulo;

					// a-a-c
					if(i-1>=0 && j+1<=300 && k-1>=0)
					dp[i-1][j+1][k-1] = (dp[i-1][j+1][k-1] + dp[i][j][k] * i * (i - 1) * k) % modulo;

					// a-c-b
					if(i-1>=0 && j-1>=0 && k-1>=0)
					dp[i-1][j-1][k-1] = (dp[i-1][j-1][k-1] + dp[i][j][k] * i * k * j) % modulo;

					// a-c-c
					if(i>=0 && j>=0 && k-2>=0)
					dp[i][j][k-2] = (dp[i][j][k-2] + dp[i][j][k] * i * k * (k - 1)) % modulo;

					// b-a-b
					if(i-1>=0 && j-1>=0 && k+1<=300)
					dp[i-1][j-1][k+1] = (dp[i-1][j-1][k+1] + dp[i][j][k] * j * i * j) % modulo;

					// b-a-c
					//

					// b-c-b
					if(i>=0 && j-2>=0 && k>=0)
					dp[i][j-2][k] = (dp[i][j-2][k] + dp[i][j][k] * j * (k + 1) * (j - 1)) % modulo;

					// b-c-c
					if(i+1<=300 && j-1>=0 && k-1>=0)
					dp[i+1][j-1][k-1] = (dp[i+1][j-1][k-1] + dp[i][j][k] * j * (k + 1) * k) % modulo;
				}
			}
		}

		cout << dp[0][0][0] << "\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 181 ms 213880 KB Output isn't correct
2 Incorrect 242 ms 213752 KB Output isn't correct
3 Incorrect 253 ms 213752 KB Output isn't correct
4 Incorrect 251 ms 213756 KB Output isn't correct
5 Incorrect 463 ms 213880 KB Output isn't correct
6 Incorrect 504 ms 213884 KB Output isn't correct
7 Incorrect 582 ms 213892 KB Output isn't correct
8 Incorrect 646 ms 213884 KB Output isn't correct
9 Incorrect 768 ms 213880 KB Output isn't correct
10 Incorrect 953 ms 214008 KB Output isn't correct