結果

問題 No.1340 おーじ君をさがせ
ユーザー tonyu0tonyu0
提出日時 2021-01-16 01:58:18
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 146,232 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-17 20:18:19
合計ジャッジ時間 6,111 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 76 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 24 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 44 ms
4,380 KB
testcase_22 AC 122 ms
4,380 KB
testcase_23 AC 44 ms
4,376 KB
testcase_24 AC 233 ms
4,380 KB
testcase_25 AC 5 ms
4,384 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 7 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 48 ms
4,376 KB
testcase_31 AC 233 ms
4,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 54 ms
4,376 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn mul(a: &Vec<Vec<bool>>, b: &Vec<Vec<bool>>) -> Vec<Vec<bool>> {
    let n = a.len();
    let m = b[0].len();
    let mut c = vec![vec![false; m]; n];
    for k in 0..n {
        for i in 0..n {
            for j in 0..m {
                c[i][j] |= a[i][k] & b[k][j];
            }
        }
    }
    c
}

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 m: usize = itr.next().unwrap().parse().unwrap();
    let mut t: usize = itr.next().unwrap().parse().unwrap();
    let mut a = vec![vec![false; n]; n];
    let mut res = vec![vec![true; n]; n];
    for _ in 0..m {
        let u: usize = itr.next().unwrap().parse().unwrap();
        let v: usize = itr.next().unwrap().parse().unwrap();
        a[u][v] = true;
    }
    while t > 0 {
        if t & 1 == 1 {
            res = mul(&res, &a);
        }
        a = mul(&a, &a);
        t >>= 1;
    }
    let from = vec![vec![true; 1]; n];
    let to = mul(&res, &from);

    let mut ans = 0;
    for i in 0..n {
        if to[i][0] {
            ans += 1;
        }
    }
    println!("{}", ans);
}
0