結果

問題 No.1937 Various Tournament
ユーザー 👑 hos.lyrichos.lyric
提出日時 2022-05-13 21:51:15
言語 D
(dmd 2.099.1)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 2,093 bytes
コンパイル時間 1,353 ms
使用メモリ 16,124 KB
最終ジャッジ日時 2023-02-21 14:03:56
合計ジャッジ時間 16,203 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
6,260 KB
testcase_01 AC 397 ms
15,972 KB
testcase_02 AC 410 ms
16,028 KB
testcase_03 AC 411 ms
16,124 KB
testcase_04 AC 410 ms
16,004 KB
testcase_05 AC 2 ms
6,176 KB
testcase_06 AC 418 ms
16,100 KB
testcase_07 AC 414 ms
16,092 KB
testcase_08 AC 2 ms
6,184 KB
testcase_09 AC 417 ms
16,040 KB
testcase_10 AC 1 ms
6,208 KB
testcase_11 AC 410 ms
16,108 KB
testcase_12 AC 414 ms
16,040 KB
testcase_13 AC 414 ms
16,012 KB
testcase_14 AC 413 ms
16,040 KB
testcase_15 AC 412 ms
16,004 KB
testcase_16 AC 413 ms
16,004 KB
testcase_17 AC 416 ms
15,972 KB
testcase_18 AC 417 ms
16,004 KB
testcase_19 AC 414 ms
16,092 KB
testcase_20 AC 2 ms
6,252 KB
testcase_21 AC 2 ms
6,248 KB
testcase_22 AC 411 ms
16,120 KB
testcase_23 AC 412 ms
16,048 KB
testcase_24 AC 411 ms
16,012 KB
testcase_25 AC 2 ms
6,196 KB
testcase_26 AC 415 ms
16,092 KB
testcase_27 AC 1 ms
6,200 KB
testcase_28 AC 411 ms
16,008 KB
testcase_29 AC 2 ms
6,260 KB
testcase_30 AC 412 ms
15,976 KB
testcase_31 AC 413 ms
16,012 KB
testcase_32 AC 415 ms
16,088 KB
testcase_33 AC 412 ms
16,012 KB
testcase_34 AC 412 ms
16,104 KB
testcase_35 AC 412 ms
16,040 KB
testcase_36 AC 414 ms
16,076 KB
testcase_37 AC 1 ms
6,192 KB
testcase_38 AC 2 ms
6,192 KB
testcase_39 AC 416 ms
16,084 KB
testcase_40 AC 2 ms
6,252 KB
testcase_41 AC 2 ms
6,180 KB
testcase_42 AC 412 ms
15,976 KB
testcase_43 AC 2 ms
6,192 KB
testcase_44 AC 1 ms
6,168 KB
testcase_45 AC 415 ms
16,076 KB
testcase_46 AC 2 ms
6,208 KB
testcase_47 AC 2 ms
6,176 KB
testcase_48 AC 2 ms
6,192 KB
testcase_49 AC 2 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt;
      auto S = new int[][](N, N);
      foreach (u; 0 .. N) foreach (v; 0 .. N) {
        S[u][v] = readInt;
      }
      
      auto dp = new long[][](1 << N, N);
      foreach (u; 0 .. N) {
        dp[1 << u][u] = 1;
      }
      foreach (p; 0 .. 1 << N) {
        const k = popcnt(p);
        if (k > 1 && !(k & k - 1)) {
          for (int q = p; q; --q &= p) if (popcnt(q) == k / 2) {
            const r = p ^ q;
            foreach (u; 0 .. N) if (q >> u & 1) foreach (v; 0 .. N) if (r >> v & 1) {
              dp[p][S[u][v] ? u : v] += dp[q][u] * dp[r][v];
            }
          }
        }
      }
      debug {
        if (N <= 2) {
          writeln(dp);
        }
      }
      
      foreach (u; 0 .. N) {
        writeln(dp[$ - 1][u]);
      }
      debug {
        writeln("========");
      }
    }
  } catch (EOFException e) {
  }
}
0