結果
問題 | No.519 アイドルユニット |
ユーザー |
|
提出日時 | 2017-06-10 14:50:49 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 770 ms / 1,000 ms |
コード長 | 776 bytes |
コンパイル時間 | 806 ms |
コンパイル使用メモリ | 119,528 KB |
実行使用メモリ | 68,700 KB |
最終ジャッジ日時 | 2024-06-12 19:56:12 |
合計ジャッジ時間 | 7,264 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop, core.stdc.stdio;immutable int INF = 1 << 28;void main() {auto N = readln.chomp.to!int;auto F = N.iota.map!(_ => readln.split.map!(to!int).array).array;auto dp = new int[](1 << N);foreach (mask; 0..(1 << N)) {if (mask.popcnt % 2 == 1) continue;int i = bsf(~mask);foreach (j; i+1..N) {if (!(mask & (1 << j))) {dp[mask | (1 << i) | (1 << j)] = max(dp[mask | (1 << i) | (1 << j)],dp[mask] + F[i][j]);}}}dp[(1 << N) - 1].writeln;}