답안 #332061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332061 2020-12-01T10:30:05 Z alextodoran Fishing Game (RMI19_fishing) C++17
0 / 100
2000 ms 71052 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 102;

const int MOD = 1e9+7;

int n, t;

int dp[3 * N_MAX][3 * N_MAX][3 * N_MAX];

bool a[3 * N_MAX], b[3 * N_MAX], c[3 * N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> 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++)
            {
                if(i == 0 && j == 0 && k == 0)
                {
                    dp[i][j][k] = 1;
                    continue;
                }
                for(int x = 1; x <= 3; x++)
                    for(int y = 1; y <= 3; y++)
                        for(int z = 1; z <= 3; z++)
                        {
                            int i1 = i, j1 = j, k1 = k;
                            bool ok = false;
                            int prod = 1;
                            if(((x == 1) ^ (i1 == 0)) == true)
                                continue;
                            if((x == 3) && k1 == 0)
                                continue;
                            if(x == 2)
                            {
                                prod *= i1;
                                i1--;
                                ok = true;
                            }
                            else if(x == 3)
                            {
                                prod *= k1;
                                j1++;
                                k1--;
                            }
                            if(((y == 1) ^ (j1 == 0)) == true)
                                continue;
                            if((y == 3) && i1 == 0)
                                continue;
                            if(y == 2)
                            {
                                prod *= j1;
                                j1--;
                                ok = true;
                            }
                            else if(y == 3)
                            {
                                prod *= i1;
                                k1++;
                                i1--;
                            }
                            if(((z == 1) ^ (k1 == 0)) == true)
                                continue;
                            if((z == 3) && j1 == 0)
                                continue;
                            if(z == 2)
                            {
                                prod *= k1;
                                k1--;
                                ok = true;
                            }
                            else if(z == 3)
                            {
                                prod *= j1;
                                i1++;
                                j1--;
                            }
                            if(ok == false)
                                continue;
                            dp[i][j][k] += 1LL * dp[i1][j1][k1] * prod % MOD;
                            if(dp[i][j][k] >= MOD)
                                dp[i][j][k] -= MOD;
                        }
            }
    while(t--)
    {
        for(int i = 1; i <= n * 3; i++)
            a[i] = b[i] = c[i] = false;
        for(int i = 1; i <= n * 2; i++)
        {
            int card;
            cin >> card;
            a[card] = true;
        }
        for(int i = 1; i <= n * 2; i++)
        {
            int card;
            cin >> card;
            b[card] = true;
        }
        for(int i = 1; i <= n * 2; i++)
        {
            int card;
            cin >> card;
            c[card] = true;
        }
        int I = 0, J = 0, K = 0;
        for(int i = 1; i <= n * 3; i++)
            I += (a[i] && b[i]);
        for(int i = 1; i <= n * 3; i++)
            J += (b[i] && c[i]);
        for(int i = 1; i <= n * 3; i++)
            K += (c[i] && a[i]);
        cout << dp[I][J][K] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Incorrect 1 ms 492 KB Output isn't correct
3 Incorrect 5 ms 1644 KB Output isn't correct
4 Incorrect 35 ms 4972 KB Output isn't correct
5 Incorrect 503 ms 28268 KB Output isn't correct
6 Incorrect 826 ms 40428 KB Output isn't correct
7 Incorrect 1310 ms 54636 KB Output isn't correct
8 Incorrect 1945 ms 71052 KB Output isn't correct
9 Execution timed out 2092 ms 68216 KB Time limit exceeded
10 Execution timed out 2078 ms 61932 KB Time limit exceeded