結果

問題 No.1937 Various Tournament
ユーザー SSRSSSRS
提出日時 2022-05-13 21:38:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,137 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 172,820 KB
実行使用メモリ 12,076 KB
最終ジャッジ日時 2023-09-29 06:41:15
合計ジャッジ時間 80,344 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> S(N, vector<int>(N));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      cin >> S[i][j];
    }
  }
  vector<vector<long long>> dp(N, vector<long long>(1 << N, 0));
  for (int i = 0; i < N; i++){
    dp[i][1 << i] = 1;
  }
  for (int i = 2; i <= N; i += 2){
    for (int j = 0; j < (1 << N); j++){
      if (__builtin_popcount(j) == i){
        for (int k = j; k > 0; k = (k - 1) & j){
          if (__builtin_popcount(k) == i / 2){
            int a = k, b = j - k;
            for (int l = 0; l < N; l++){
              if ((a >> l & 1) == 1){
                for (int m = 0; m < N; m++){
                  if ((b >> m & 1) == 1){
                    if (S[l][m] == 1){
                      dp[l][j] += dp[l][a] * dp[m][b];
                    } else {
                      dp[m][j] += dp[l][a] * dp[m][b];
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++){
    cout << dp[i][(1 << N) - 1] << endl;
  }
}
0