結果

問題 No.1937 Various Tournament
ユーザー RubikunRubikun
提出日時 2022-05-13 22:06:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 326 ms / 2,000 ms
コード長 1,606 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 199,764 KB
実行使用メモリ 11,712 KB
最終ジャッジ日時 2023-09-29 07:24:46
合計ジャッジ時間 13,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 311 ms
11,440 KB
testcase_02 AC 320 ms
11,392 KB
testcase_03 AC 321 ms
11,456 KB
testcase_04 AC 320 ms
11,508 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 324 ms
11,516 KB
testcase_07 AC 322 ms
11,424 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 325 ms
11,444 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 321 ms
11,464 KB
testcase_12 AC 322 ms
11,692 KB
testcase_13 AC 323 ms
11,440 KB
testcase_14 AC 322 ms
11,388 KB
testcase_15 AC 323 ms
11,508 KB
testcase_16 AC 322 ms
11,412 KB
testcase_17 AC 321 ms
11,484 KB
testcase_18 AC 326 ms
11,468 KB
testcase_19 AC 321 ms
11,452 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 321 ms
11,444 KB
testcase_23 AC 321 ms
11,408 KB
testcase_24 AC 320 ms
11,484 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 320 ms
11,576 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 319 ms
11,388 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 321 ms
11,540 KB
testcase_31 AC 319 ms
11,612 KB
testcase_32 AC 324 ms
11,420 KB
testcase_33 AC 321 ms
11,448 KB
testcase_34 AC 322 ms
11,420 KB
testcase_35 AC 322 ms
11,392 KB
testcase_36 AC 322 ms
11,444 KB
testcase_37 AC 2 ms
4,384 KB
testcase_38 AC 2 ms
4,384 KB
testcase_39 AC 323 ms
11,712 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 323 ms
11,480 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 322 ms
11,416 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005;
const ll INF=1LL<<60;

int S[16][16];

ll dp[1<<16][16];
bool seen[1<<16][16];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    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];
        }
    }
    
    for(int i=0;i<N;i++) dp[(1<<i)][i]=1;
    for(int bit=0;bit<(1<<N);bit++){
        int x=__builtin_popcount(bit);
        if(!(x==2||x==4||x==8||x==16)) continue;
        for(int T=bit;;T=(T-1)&bit){
            int y=__builtin_popcount(T);
            if(y+y!=x){
                if(T==0) break;
                else continue;
            }
            int U=bit-T;
            for(int i=0;i<N;i++){
                if(!(T&(1<<i))) continue;
                for(int j=0;j<N;j++){
                    if(!(U&(1<<j))) continue;
                    if(S[i][j]) dp[bit][i]+=dp[T][i]*dp[U][j];
                    else dp[bit][j]+=dp[T][i]*dp[U][j];
                }
            }
            
            if(T==0) break;
        }
    }
    
    for(int i=0;i<N;i++) cout<<dp[(1<<N)-1][i]<<"\n";
}

0