結果

問題 No.2566 美しい整数列
コンテスト
ユーザー kv5h
提出日時 2023-12-15 19:46:21
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 1,354 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,483 ms
コンパイル使用メモリ 195,172 KB
実行使用メモリ 9,968 KB
最終ジャッジ日時 2026-04-14 02:38:23
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2 RE * 1
other WA * 1 RE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::Chars},
    std::{
        cmp::Reverse,
        collections::{BinaryHeap, HashMap, HashSet, VecDeque},
        convert::TryInto,
        io::{self, stdout, BufWriter, Write},
    },
};

#[fastout]
fn main() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    input! {h: usize, w: usize, mtx: [[u32; w];h]}

    let mut max = 0;
    for bit in 1..(1 << h) {
        let mut hvec: Vec<u32> = Vec::new();
        for hh in 0..h as u32 {
            let mask = 1 << hh;
            if mask & bit != 0 {
                hvec.push(hh);
            }
        }
        let mut fst = 0;
        let mut tmp = 0;
        for wid in 0..w {
            let mut flg = true;
            for (i, v) in hvec.iter().enumerate() {
                if wid == 0 && i == 0 {
                    fst = mtx[*v as usize][wid];
                    continue;
                }
                if fst != mtx[*v as usize][wid] {
                    flg = false;
                }
            }
            if flg {
                tmp += hvec.len();
            }
        }
        println!("max: {}, hvec: {:?}, fst: {}", max, hvec, fst);
        max = max.max(tmp);
    }
    //let max = if max > 0 { max } else { 1 };
    writeln!(out, "{}", max).unwrap();
}
0