結果

問題 No.1477 Lamps on Graph
ユーザー StrorkisStrorkis
提出日時 2021-04-16 21:45:52
言語 Rust
(1.72.1)
結果
WA  
実行時間 -
コード長 1,379 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 155,692 KB
実行使用メモリ 16,264 KB
最終ジャッジ日時 2023-09-16 00:06:01
合計ジャッジ時間 5,418 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 29 ms
8,748 KB
testcase_13 AC 27 ms
8,176 KB
testcase_14 AC 35 ms
9,472 KB
testcase_15 AC 16 ms
5,520 KB
testcase_16 AC 13 ms
5,248 KB
testcase_17 AC 13 ms
4,452 KB
testcase_18 AC 36 ms
9,380 KB
testcase_19 AC 28 ms
8,592 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 30 ms
8,064 KB
testcase_22 AC 6 ms
4,384 KB
testcase_23 AC 20 ms
6,984 KB
testcase_24 AC 40 ms
10,024 KB
testcase_25 AC 13 ms
4,984 KB
testcase_26 AC 41 ms
10,472 KB
testcase_27 AC 18 ms
5,808 KB
testcase_28 AC 24 ms
7,812 KB
testcase_29 AC 22 ms
7,336 KB
testcase_30 AC 17 ms
5,376 KB
testcase_31 AC 14 ms
5,376 KB
testcase_32 AC 54 ms
16,264 KB
testcase_33 AC 51 ms
15,428 KB
testcase_34 WA -
testcase_35 AC 62 ms
14,908 KB
testcase_36 AC 66 ms
14,948 KB
testcase_37 AC 58 ms
14,960 KB
testcase_38 AC 58 ms
14,912 KB
testcase_39 AC 61 ms
14,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Write;

fn main() {
    let ref mut buf = Vec::new();
    std::io::Read::read_to_end(&mut std::io::stdin(), buf).ok();
    let mut iter = std::str::from_utf8(buf).unwrap().split_whitespace();

    macro_rules! scan {
        ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::<Vec<_>>());
        (($($t:tt),*)) => (($(scan!($t)),*));
        (Usize1) => (scan!(usize) - 1);
        (Bytes) => (scan!(String).into_bytes());
        ($t:ty) => (iter.next().unwrap().parse::<$t>().unwrap());
    }

    let (n, m) = scan!((usize, usize));
    let a = scan!([u32; n]);

    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let (u, v) = scan!((Usize1, Usize1));
        g[u].push(v);
        g[v].push(u);
    }

    let k = scan!(usize);

    let mut lit = vec![false; n];
    for _ in 0..k {
        let b = scan!(Usize1);
        lit[b] = true;
    }

    let mut ord = (0..n).collect::<Vec<_>>();
    ord.sort_by_key(|&i| a[i]);

    let mut ans = vec![];
    for from in ord {
        if !lit[from] {
            continue;
        }
        ans.push(from);
        for &to in &g[from] {
            lit[to] ^= true;
        }
    }

    let stdout = std::io::stdout();
    let mut writer = std::io::BufWriter::new(stdout.lock());

    writeln!(writer, "{}", ans.len()).ok();
    for ans in ans {
        writeln!(writer, "{}", ans + 1).ok();
    }
}
0