結果

問題 No.1340 おーじ君をさがせ
ユーザー tonyu0tonyu0
提出日時 2021-01-16 02:00:27
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,292 bytes
コンパイル時間 12,867 ms
コンパイル使用メモリ 377,588 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 03:13:25
合計ジャッジ時間 16,352 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 33 ms
5,376 KB
testcase_14 AC 89 ms
5,376 KB
testcase_15 AC 77 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 25 ms
5,376 KB
testcase_18 AC 45 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 46 ms
5,376 KB
testcase_22 AC 123 ms
5,376 KB
testcase_23 AC 45 ms
5,376 KB
testcase_24 AC 234 ms
5,376 KB
testcase_25 AC 6 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 7 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 48 ms
5,376 KB
testcase_31 AC 238 ms
5,376 KB
testcase_32 AC 222 ms
5,376 KB
testcase_33 AC 235 ms
5,376 KB
testcase_34 AC 194 ms
5,376 KB
testcase_35 AC 240 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 237 ms
5,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 54 ms
5,376 KB
testcase_50 AC 54 ms
5,376 KB
testcase_51 AC 54 ms
5,376 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 1 ms
5,376 KB
testcase_57 AC 0 ms
5,376 KB
testcase_58 AC 0 ms
5,376 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![false; 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;
        res[u][v] = true;
    }
    while t > 0 {
        if t & 1 == 1 {
            res = mul(&res, &a);
        }
        a = mul(&a, &a);
        t >>= 1;
    }
    let mut from = vec![vec![false; 1]; n];
    from[0][0] = true;
    let to = mul(&res, &from);

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