結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 40 ms
4,376 KB
testcase_14 AC 114 ms
4,376 KB
testcase_15 AC 96 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 31 ms
4,376 KB
testcase_18 AC 55 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 56 ms
4,380 KB
testcase_22 AC 153 ms
4,376 KB
testcase_23 AC 56 ms
4,380 KB
testcase_24 AC 293 ms
4,380 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 9 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 60 ms
4,380 KB
testcase_31 AC 294 ms
4,376 KB
testcase_32 AC 274 ms
4,376 KB
testcase_33 AC 271 ms
4,376 KB
testcase_34 AC 244 ms
4,376 KB
testcase_35 AC 296 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 294 ms
4,384 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 67 ms
4,380 KB
testcase_50 AC 68 ms
4,380 KB
testcase_51 AC 67 ms
4,380 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,380 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![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