Submission #332831

# Submission time Handle Problem Language Result Execution time Memory
332831 2020-12-03T15:56:11 Z kapsel Fishing Game (RMI19_fishing) C++17
10 / 100
226 ms 121500 KB
#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double

const int N = 204;
int dp[N][N][N][3][2];
bool good[N][N][N][3][2];

int solve(int a, int b, int c, int x, int d) {
	if(a+b+c == 0)
		return 1;
	if(x == 3) {
		if(!d)
			return 0;
		return solve(a, b, c, 0, 0);
	}
	if(good[a][b][c][x][d]) return dp[a][b][c][x][d];
	good[a][b][c][x][d] = 1;
	if(x == 0) {
		if(a+c == 0) return dp[a][b][c][x][d] = solve(a, b, c, x+1, d);
		if(a) dp[a][b][c][x][d] += a * solve(a-1, b, c, x+1, 1);
		if(c) dp[a][b][c][x][d] += c * solve(a, b+1, c-1, x+1, d);
		return dp[a][b][c][x][d];
	}
	if(x == 1) {
		if(a+b == 0) return dp[a][b][c][x][d] = solve(a, b, c, x+1, d);
		if(b) dp[a][b][c][x][d] += b * solve(a, b-1, c, x+1, 1);
		if(a) dp[a][b][c][x][d] += a * solve(a-1, b, c+1, x+1, d);
		return dp[a][b][c][x][d];
	}
	if(x == 2) {
		if(b+c == 0) return dp[a][b][c][x][d] = solve(a, b, c, x+1, d);
		if(c) dp[a][b][c][x][d] += c * solve(a, b, c-1, x+1, 1);
		if(b) dp[a][b][c][x][d] += b * solve(a+1, b-1, c, x+1, d);
		return dp[a][b][c][x][d];
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, t;
	cin>>n>>t;
	while(t--) {
		set<int> l[3];
		int a = 0, b = 0, c = 0;
		for(int i=0; i<3; i++) {
			for(int j=0; j<2*n; j++) {
				int r;
				cin>>r;
				l[i].insert(r);
			}
		}
		for(int i=1; i<=(3*n); i++) {
			if(l[0].count(i) && l[1].count(i))
				a++;
			if(l[1].count(i) && l[2].count(i))
				b++;
			if(l[2].count(i) && l[0].count(i))
				c++;
		}
		cout<<solve(a, b, c, 0, 0)<<"\n";
	}
}

Compilation message

fishing.cpp: In function 'int solve(int, int, int, int, int)':
fishing.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Incorrect 1 ms 492 KB Output isn't correct
3 Incorrect 2 ms 1792 KB Output isn't correct
4 Incorrect 4 ms 5612 KB Output isn't correct
5 Incorrect 37 ms 32108 KB Output isn't correct
6 Incorrect 53 ms 45548 KB Output isn't correct
7 Incorrect 89 ms 61420 KB Output isn't correct
8 Incorrect 122 ms 79852 KB Output isn't correct
9 Incorrect 173 ms 100588 KB Output isn't correct
10 Incorrect 226 ms 121500 KB Output isn't correct