답안 #291500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291500 2020-09-05T12:15:30 Z nicolaalexandra Fishing Game (RMI19_fishing) C++14
0 / 100
166 ms 36728 KB
#include <bits/stdc++.h>
#define DIM 210
#define MOD 1000000007
using namespace std;

int dp[DIM][DIM][DIM],fa[DIM*2],fb[DIM*2],fc[DIM*3],a[DIM],b[DIM],c[DIM];
int t,n,i,j,k;

int main (){

    //ifstream cin ("fishing.in");
    //ofstream cout ("fishing.out");

    cin>>n>>t;
    for (;t--;){

        memset (fa,0,sizeof fa);
        memset (fb,0,sizeof fb);
        memset (fc,0,sizeof fc);

        for (i=1;i<=2*n;i++){
            cin>>a[i];
            fa[a[i]]++;
        }

        for (i=1;i<=2*n;i++){
            cin>>b[i];
            fb[b[i]]++;
        }
        for (i=1;i<=2*n;i++){
            cin>>c[i];
            fc[c[i]]++;
        }

        int nr_ab = 0, nr_ac = 0, nr_bc = 0;
        for (i=1;i<=3*n;i++){
            if (fa[i] && fb[i]) /// cate au in comun a si b
                nr_ab++;
            if (fa[i] && fc[i]) /// cate au in comun a si c
                nr_ac++;
            if (fb[i] && fc[i]) /// cate au in comun b si c
                nr_bc++;
        }

        memset (dp,0,sizeof dp);
        dp[nr_ab][nr_ac][nr_bc] = 1;

        for (i=nr_ab;i>=0;i--){
            for (j=nr_ac;j>=0;j--){
                for (k=nr_bc;k>=0;k--){

                    if (!dp[i][j][k]) /// nu am calculat starea asta
                        continue;

                    /// A -> B -> C -> A

                    int nr_ab = i, nr_ac = j, nr_bc = k, sol1, sol2, sol3;
                    int ok = 0; /// daca am eliminat sau nu o carte

                    for (int tip_a=0;tip_a<=1;tip_a++){
                        /// A -> B
                        if (!tip_a){
                            sol1 = nr_ab;
                            nr_ab--;
                        } else {
                            sol1 = nr_ac;
                            nr_ac--, nr_bc++;
                        }

                        for (int tip_b=0;tip_b<=1;tip_b++){

                            /// B -> C

                            if (!tip_b){
                                sol2 = nr_bc;
                                nr_bc--;
                            } else {
                                sol2 = nr_ab;
                                nr_ab--, nr_ac++;
                            }

                            for (int tip_c=0;tip_c<=1;tip_c++){

                                /// C -> A
                                if (!tip_c){
                                    sol3 = nr_ac;
                                    nr_ac--;
                                } else {
                                    sol3 = nr_bc;
                                    nr_bc--, nr_ab++;
                                }

                                if (!(nr_ab == i && nr_ac == j && nr_bc == k) && sol1 > 0 && sol2 > 0 && sol3 > 0){
                                    dp[nr_ab][nr_ac][nr_bc] += 1LL * dp[i][j][k] * sol1 % MOD * sol2 % MOD * sol3 % MOD;
                                    if (dp[nr_ab][nr_ac][nr_bc] >= MOD)
                                        dp[nr_ab][nr_ac][nr_bc] -= MOD;
                                }

                                (!tip_c) ? (nr_ac++) : (nr_bc++, nr_ab--);

                            }

                            (!tip_b) ? (nr_bc++) : (nr_ab++, nr_ac--);

                        }

                        /// reverse
                        (!tip_a) ? (nr_ab++) : (nr_ac++, nr_bc--);
                    }}}}}

    cout<<dp[0][0][0];


    return 0;
}

Compilation message

fishing.cpp: In function 'int main()':
fishing.cpp:58:25: warning: unused variable 'ok' [-Wunused-variable]
   58 |                     int ok = 0; /// daca am eliminat sau nu o carte
      |                         ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 36608 KB Output isn't correct
2 Incorrect 37 ms 36600 KB Output isn't correct
3 Incorrect 42 ms 36608 KB Output isn't correct
4 Incorrect 40 ms 36568 KB Output isn't correct
5 Incorrect 77 ms 36624 KB Output isn't correct
6 Incorrect 86 ms 36728 KB Output isn't correct
7 Incorrect 98 ms 36632 KB Output isn't correct
8 Incorrect 117 ms 36608 KB Output isn't correct
9 Incorrect 135 ms 36608 KB Output isn't correct
10 Incorrect 166 ms 36608 KB Output isn't correct