結果

問題 No.43 野球の試合
ユーザー tonyu0tonyu0
提出日時 2020-03-24 21:09:56
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,300 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 158,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 07:24:59
合計ジャッジ時間 1,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 14 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let grid: Vec<Vec<char>> = (0..n)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();
    let mut m = Vec::new();
    for i in 0..n {
        for j in i + 1..n {
            if grid[i][j] == '-' {
                m.push((i, j));
            }
        }
    }

    let mut ans = 10;
    for bit in 0..(1 << m.len()) {
        let mut now = grid.clone();
        let mut point = Vec::new();
        for i in 0..m.len() {
            if bit >> i & 1 == 1 {
                now[m[i].0][m[i].1] = 'o';
                now[m[i].1][m[i].0] = 'x';
            }
        }

        for i in 0..n {
            let mut p = 0;
            for j in 0..n {
                if i != j {
                    if now[i][j] == 'o' {
                        p += 1;
                    }
                }
            }
            point.push((p, i));
        }
        point.sort_by(|a, b| b.0.cmp(&a.0));
        for i in 0..n {
            if point[i].1 == 0 {
                ans = std::cmp::min(ans, i + 1);
            }
        }
    }
    println!("{}", ans);
}
0