結果
問題 | No.43 野球の試合 |
ユーザー | te-sh |
提出日時 | 2016-08-31 14:00:49 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 89 ms / 5,000 ms |
コード長 | 1,329 bytes |
コンパイル時間 | 1,074 ms |
コンパイル使用メモリ | 119,128 KB |
実行使用メモリ | 4,372 KB |
最終ジャッジ日時 | 2023-09-02 21:44:33 |
合計ジャッジ時間 | 1,764 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,372 KB |
testcase_01 | AC | 1 ms
4,372 KB |
testcase_02 | AC | 1 ms
4,372 KB |
testcase_03 | AC | 1 ms
4,372 KB |
testcase_04 | AC | 1 ms
4,368 KB |
testcase_05 | AC | 1 ms
4,372 KB |
testcase_06 | AC | 2 ms
4,372 KB |
testcase_07 | AC | 89 ms
4,368 KB |
testcase_08 | AC | 1 ms
4,372 KB |
testcase_09 | AC | 1 ms
4,372 KB |
testcase_10 | AC | 1 ms
4,368 KB |
ソースコード
import std.algorithm, std.array, std.container, std.range; import std.numeric, std.math, std.bigint, std.bitmanip, std.random; import std.string, std.conv, std.stdio, std.typecons; enum Game { NA, NotYet, Win, Lose } alias Tuple!(int, int) pos; void main() { auto n = readln.chomp.to!int; auto tij = iota(n).map!((i) { return readln.chomp.map!((c) { switch (c) { case '#': return Game.NA; case '-': return Game.NotYet; case 'o': return Game.Win; case 'x': return Game.Lose; default: assert(0); } }).array; }).array; pos[] ai; foreach (i; 0..n) foreach (j; i + 1..n) if (tij[i][j] == Game.NotYet) ai ~= pos(i, j); if (!ai.empty) { auto min = n; foreach (i; 0..2 ^^ ai.length) { auto b = bitsSet(i); auto uij = tij.dup.map!(dup).array; foreach (j, a; ai) { uij[a[0]][a[1]] = b.canFind(j) ? Game.Win : Game.Lose; uij[a[1]][a[0]] = b.canFind(j) ? Game.Lose : Game.Win; } auto r = calcRank(uij); if (r < min) min = r; } writeln(min); } else { writeln(calcRank(tij)); } } int calcRank(Game[][] tij) { auto wi = tij.map!(a => a.count!(b => b == Game.Win)).array; auto w = wi.front; auto x = wi.sort!("a > b").uniq.array; return x.until(w).array.length.to!int + 1; }