답안 #274361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
274361 2020-08-19T11:17:22 Z theStaticMind Fishing Game (RMI19_fishing) C++14
0 / 100
1228 ms 214048 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;
/*
					dp[i-1][j][k] , i 
					dp[i-1][j][k] , i 
					dp[i-1][j][k] , i 
					dp[i-1][j][k] , i 

					dp[i][j-1][k+1], j
					dp[i][j-1][k+1], j
					dp[i][j-1][k+1], j
					dp[i][j-1][k+1], j
///////////////////////////////////////////////////////////////////////////
					dp[i-2][j+1][k] , i * (i-1) 
					dp[i-2][j+1][k] , i * (i-1)
					dp[i-1][j][k-1] , i * k
					dp[i-1][j][k-1] , i * k

					dp[i-1][j][k+1], j * i
					dp[i-1][j][k+1], j * i
					dp[i][j-1][k], j * (k+1)
					dp[i][j-1][k], j * (k+1)
					///////////////////////////////////////////////////////////////////////////
				+	dp[i-2][j][k] , i * (i-1) * (j+1)
				+	dp[i-1][j+1][k-1] , i * (i-1) * k
				+	dp[i-1][j-1][k-1] , i * k * j
				+	dp[i][j][k-2] , i * k * (k-1)
				+	dp[i-1][j-1][k+1], j * i * j
				+	dp[i][j][k], j * i * (k+1)
				+	dp[i][j-2][k], j * (k+1) * (j-1)
				+	dp[i+1][j-1][k-1], j * (k+1) * k
*/
					// a-a-b
					if(i-2>=0 && j>=0 && k>=0)
					dp[i-2][j][k] = (dp[i-2][j][k] + 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 255 ms 213752 KB Output isn't correct
2 Incorrect 286 ms 213732 KB Output isn't correct
3 Incorrect 287 ms 213772 KB Output isn't correct
4 Incorrect 252 ms 213832 KB Output isn't correct
5 Incorrect 646 ms 213892 KB Output isn't correct
6 Incorrect 772 ms 213880 KB Output isn't correct
7 Incorrect 699 ms 214008 KB Output isn't correct
8 Incorrect 799 ms 213884 KB Output isn't correct
9 Incorrect 1172 ms 214048 KB Output isn't correct
10 Incorrect 1228 ms 213880 KB Output isn't correct