結果

問題 No.1937 Various Tournament
ユーザー HaaHaa
提出日時 2022-05-13 22:22:31
言語 C++14
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 1,117 bytes
コンパイル時間 1,406 ms
実行使用メモリ 14,000 KB
最終ジャッジ日時 2023-02-21 15:15:25
合計ジャッジ時間 14,983 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,276 KB
testcase_01 AC 379 ms
14,000 KB
testcase_02 AC 366 ms
13,864 KB
testcase_03 AC 366 ms
13,860 KB
testcase_04 AC 362 ms
13,868 KB
testcase_05 AC 2 ms
6,204 KB
testcase_06 AC 364 ms
13,868 KB
testcase_07 AC 362 ms
13,864 KB
testcase_08 AC 1 ms
6,252 KB
testcase_09 AC 364 ms
13,868 KB
testcase_10 AC 1 ms
6,272 KB
testcase_11 AC 366 ms
13,908 KB
testcase_12 AC 365 ms
13,864 KB
testcase_13 AC 362 ms
13,936 KB
testcase_14 AC 363 ms
13,972 KB
testcase_15 AC 361 ms
13,912 KB
testcase_16 AC 361 ms
13,868 KB
testcase_17 AC 365 ms
14,000 KB
testcase_18 AC 361 ms
13,960 KB
testcase_19 AC 360 ms
14,000 KB
testcase_20 AC 2 ms
6,176 KB
testcase_21 AC 2 ms
6,260 KB
testcase_22 AC 362 ms
13,932 KB
testcase_23 AC 365 ms
13,992 KB
testcase_24 AC 363 ms
13,936 KB
testcase_25 AC 1 ms
6,252 KB
testcase_26 AC 363 ms
13,872 KB
testcase_27 AC 1 ms
6,164 KB
testcase_28 AC 367 ms
13,860 KB
testcase_29 AC 2 ms
6,176 KB
testcase_30 AC 365 ms
13,988 KB
testcase_31 AC 366 ms
13,864 KB
testcase_32 AC 363 ms
13,860 KB
testcase_33 AC 360 ms
13,900 KB
testcase_34 AC 362 ms
13,864 KB
testcase_35 AC 363 ms
13,916 KB
testcase_36 AC 361 ms
13,920 KB
testcase_37 AC 1 ms
6,320 KB
testcase_38 AC 2 ms
6,268 KB
testcase_39 AC 375 ms
13,924 KB
testcase_40 AC 2 ms
6,204 KB
testcase_41 AC 1 ms
6,208 KB
testcase_42 AC 365 ms
13,856 KB
testcase_43 AC 2 ms
6,200 KB
testcase_44 AC 2 ms
6,196 KB
testcase_45 AC 363 ms
13,948 KB
testcase_46 AC 2 ms
6,208 KB
testcase_47 AC 1 ms
6,208 KB
testcase_48 AC 1 ms
6,188 KB
testcase_49 AC 2 ms
6,176 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