Submission #853739

# Submission time Handle Problem Language Result Execution time Memory
853739 2023-09-25T07:21:44 Z heeheeheehaaw Fishing Game (RMI19_fishing) C++17
0 / 100
381 ms 218084 KB
#include <iostream>
#define int long long

using namespace std;

int v[4][305];
int dp[305][305][305];
const int MOD = 1e9 + 7;

signed main()
{
    int n, t;
    cin>>n>>t;
    while(t--)
    {
        for(int i = 0; i <= 3*n; i++)
            for(int j = 0; j <= 3*n; j++)
                for(int k = 0; k <= 3*n; k++)
                    dp[i][j][k] = 0;
        for(int i = 1; i <= 3; i++)
            for(int j = 1; j <= 2*n; j++)
                cin>>v[i][j];

        int p12 = 0, p23 = 0, p31 = 0;
        for(int i = 1; i <= 2*n; i++)
            for(int j = 1; j <= 2*n; j++)
                if(v[1][i] == v[2][j])
                    p12++;
        for(int i = 1; i <= 2*n; i++)
            for(int j = 1; j <= 2*n; j++)
                if(v[2][i] == v[3][j])
                    p23++;
        for(int i = 1; i <= 2*n; i++)
            for(int j = 1; j <= 2*n; j++)
                if(v[3][i] == v[1][j])
                    p31++;
        dp[p12][p23][p31] = 1;
        for(int tot = p12 + p23 + p31; tot > 0; tot--)
        {
            for(int c12=0; c12<=tot; c12++)
            {
                for(int c23=0; c23+c12<=tot; c23++)
                {
                    int c31=tot-c12-c23;
                    if(dp[c12][c23][c31] == 0)
                        continue;
                    for(int a = 1; a <= 2; a++)
                    {
                        for(int b = 1; b <= 2; b++)
                        {
                            for(int c = 1; c <= 2; c++)
                            {
                                int ct12 = c12, ct23 = c23, ct31 = c31, prod = 1;

                                if(ct12 > 0 || ct31 > 0)
                                {
                                    if(a == 1)
                                        prod *= ct31, ct23++, ct31--, prod %= MOD;
                                    else
                                        prod *= ct12, ct12--, prod %= MOD;
                                }

                                if(ct23 > 0 || ct12 > 0)
                                {
                                    if(b == 1)
                                        prod *= ct12, ct31++, ct12--, prod %= MOD;
                                    else
                                        prod *= ct23, ct23--, prod %= MOD;
                                }

                                if(ct31 > 0 || ct23 > 0)
                                {
                                    if(c == 1)
                                        prod *= ct23, ct12++, ct23--, prod %= MOD;
                                    else
                                        prod *= ct31, ct31--, prod %= MOD;
                                }

                                if(ct12 >= 0 && ct23 >= 0 && ct31 >= 0 && ct12 + ct23 + ct31 < tot)
                                    dp[ct12][ct23][ct31] += dp[c12][c23][c31] * prod % MOD, dp[ct12][ct23][ct31] %= MOD;

                            }
                        }
                    }
                }
            }
        }

        cout<<dp[0][0][0]<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Incorrect 2 ms 8540 KB Output isn't correct
3 Incorrect 4 ms 22876 KB Output isn't correct
4 Incorrect 6 ms 45660 KB Output isn't correct
5 Incorrect 67 ms 111196 KB Output isn't correct
6 Incorrect 125 ms 131932 KB Output isn't correct
7 Incorrect 161 ms 154460 KB Output isn't correct
8 Incorrect 229 ms 176984 KB Output isn't correct
9 Incorrect 301 ms 199664 KB Output isn't correct
10 Incorrect 381 ms 218084 KB Output isn't correct