結果

問題 No.2435 Order All Company
ユーザー yuyu_5510yuyu_5510
提出日時 2023-08-11 21:17:37
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 3,097 ms
コンパイル使用メモリ 132,468 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-15 15:10:22
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
const long long mod = 998244353;

int main(){
    int N, K;
    cin >> N >> K;
    vector G(K, vector(N, vector(N, 0LL)));
    for(int i = 0;i < K;i++){
        int t;
        cin >> t;
        for(int j = 0;j < t;j++){
            int a, b;
            cin >> a >> b;
            --a;--b;
            G[i][a][b] += 1;
            G[i][b][a] += 1;
        }
    }

    vector<vector<long long>> dp(N+1, vector<long long>(1<<K, 0));
    dp[1][0] = 1;


    for(int i = 1;i < N;i++){
        for(int j = 0;j < 1<<K;j++){
            for(int k = 0;k < K;k++){
                for(int l = 0;l < i;l++){
                    dp[i+1][j | 1<<k] += (G[k][l][i] * dp[i][j]) % mod;
                    dp[i+1][j | 1<<k] %= mod;
                }
            }
        }
    }

    cout << dp[N][(1<<K)-1] << endl;

}
0