結果

問題 No.1937 Various Tournament
ユーザー HaaHaa
提出日時 2022-05-13 22:22:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 1,117 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 170,472 KB
実行使用メモリ 14,124 KB
最終ジャッジ日時 2023-09-29 07:48:52
合計ジャッジ時間 15,077 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 379 ms
13,868 KB
testcase_02 AC 369 ms
14,056 KB
testcase_03 AC 370 ms
13,748 KB
testcase_04 AC 369 ms
13,904 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 366 ms
13,812 KB
testcase_07 AC 367 ms
13,892 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 369 ms
13,888 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 369 ms
13,864 KB
testcase_12 AC 370 ms
14,112 KB
testcase_13 AC 366 ms
13,744 KB
testcase_14 AC 369 ms
13,908 KB
testcase_15 AC 366 ms
13,792 KB
testcase_16 AC 368 ms
13,852 KB
testcase_17 AC 367 ms
13,864 KB
testcase_18 AC 367 ms
13,988 KB
testcase_19 AC 374 ms
13,752 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 369 ms
13,784 KB
testcase_23 AC 370 ms
13,872 KB
testcase_24 AC 366 ms
13,800 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 367 ms
13,788 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 371 ms
14,124 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 368 ms
13,904 KB
testcase_31 AC 370 ms
13,956 KB
testcase_32 AC 366 ms
13,868 KB
testcase_33 AC 365 ms
13,988 KB
testcase_34 AC 365 ms
13,868 KB
testcase_35 AC 369 ms
13,820 KB
testcase_36 AC 363 ms
13,888 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 368 ms
13,796 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 367 ms
13,896 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 364 ms
13,900 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int popc(int x){
    int ret=0;
    REP(i,20){
        ret+=x&1;
        x>>=1;
    }
    return ret;
}

int main(){
    int n; cin >> n;
    VVI s(n,VI(n));
    REP(i,n)REP(j,n) cin >> s[i][j];
    VVI dp(1<<n,VI(n,0));
    REP(i,n) dp[1<<i][i]=1;
    REP(i,1<<n){
        int ipc=popc(i);
        if(ipc==1||popc(ipc)!=1) continue;
        for(int j=i;j>0;j=((j-1)&i)){
            if(popc(j)!=ipc/2) continue;
            REP(x,n)REP(y,n){
                if(s[x][y]){
                    dp[i][x]+=dp[j][x]*dp[i^j][y];
                    dp[i][x]+=dp[i^j][x]*dp[j][y];
                }
            }
        }
    }
    REP(i,n) cout << dp[(1<<n)-1][i] << endl;
    return 0;
}
0