結果

問題 No.1937 Various Tournament
ユーザー tarattata1tarattata1
提出日時 2022-05-13 22:56:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,070 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 92,644 KB
実行使用メモリ 7,868 KB
最終ジャッジ日時 2023-09-29 08:37:38
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <ctime>
#include <bitset>
#pragma warning(disable:4996) 

//#define ATCODER
#ifdef ATCODER
#include <atcoder/all>
#endif

typedef long long ll;
typedef unsigned long long ull;
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
#ifdef ATCODER
using namespace atcoder;
#endif

int a[16][16];
ll ans[16];
ll anssum;

void calc(vector<int>& v, int i0)
{
    if (v.size() == 1) {
        assert(i0 == 0);
        ans[v[0]]++;
        anssum++;
    }
    else if (i0 == v.size()) {
        vector<int> v2;
        for (int k = 0; k < i0 / 2; k++) {
            int t0 = v[k * 2], t1 = v[k * 2 + 1];
            if (a[t0][t1]) v2.push_back(t0);
            else v2.push_back(t1);            
        }
        calc(v2, 0);
    }
    else {
        int num = (int)v.size();
        int i1 = i0 + 1;
        for (int k = i1; k < num; k++) {
            swap(v[i1], v[k]);
            calc(v, i0 + 2);
            swap(v[i1], v[k]);
        }
    }
}

void solve()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    vector<int> v;
    for (int i = 0; i < n; i++) {
        v.push_back(i);
    }

    calc(v, 0);

    int cnt = 0;
    ll num = 1;
    for (int k = n; k >= 1; k--) {
        num *= k;
    }
    ll n0 = num / anssum;
    for (int i = 0; i < n; i++) {
        printf("%d\n", ans[i]*n0);
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T, t;
    scanf("%d", &T);
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}
0