提出 #47185709


ソースコード 拡げる

#![allow(unused_imports)]

const MAX: usize = 1_000_000;

fn dfs(graph: &[Vec<usize>], seen: &mut [bool], now: usize, mut cnt: usize) -> Option<usize> {
    cnt += 1;
    if cnt == MAX {
        return None;
    }
    seen[now] = true;
    for &next in &graph[now] {
        if !seen[next] {
            cnt = dfs(graph, seen, next, cnt)?;
        }
    }
    seen[now] = false;
    Some(cnt)
}

fn main() {
    input! {
        n: usize, m: usize,
    }
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        input! {
            u: Usize1, v: Usize1,
        }
        graph[u].push(v);
        graph[v].push(u);
    }
    let ans = dfs(&graph, &mut vec![false; n], 0, 0).unwrap_or(MAX);
    println!("{ans}");
}

use proconio::{input, marker::*};

提出情報

提出日時
問題 E - Count Simple Paths
ユーザ QiToY
言語 Rust (rustc 1.70.0)
得点 500
コード長 760 Byte
結果 AC
実行時間 115 ms
メモリ 34064 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 33
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 01_small_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 03_random_2_00.txt, 03_random_2_01.txt, 03_random_2_02.txt, 03_random_2_03.txt, 03_random_2_04.txt, 04_corner_00.txt, 04_corner_01.txt, 04_corner_02.txt, 04_corner_03.txt, 04_corner_04.txt, 04_corner_05.txt, 05_path_00.txt, 05_path_01.txt, 06_m_eq_0_00.txt, 07_n_eq_1_00.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 2024 KiB
00_sample_01.txt AC 1 ms 1928 KiB
00_sample_02.txt AC 1 ms 1928 KiB
01_small_00.txt AC 1 ms 1872 KiB
01_small_01.txt AC 1 ms 1804 KiB
01_small_02.txt AC 1 ms 2064 KiB
01_small_03.txt AC 1 ms 2060 KiB
01_small_04.txt AC 1 ms 1808 KiB
01_small_05.txt AC 1 ms 2084 KiB
01_small_06.txt AC 2 ms 1976 KiB
01_small_07.txt AC 1 ms 1872 KiB
01_small_08.txt AC 12 ms 1928 KiB
01_small_09.txt AC 1 ms 1916 KiB
02_random_00.txt AC 29 ms 8632 KiB
02_random_01.txt AC 9 ms 2124 KiB
02_random_02.txt AC 7 ms 2032 KiB
02_random_03.txt AC 115 ms 21720 KiB
02_random_04.txt AC 58 ms 17572 KiB
03_random_2_00.txt AC 36 ms 13260 KiB
03_random_2_01.txt AC 31 ms 13028 KiB
03_random_2_02.txt AC 25 ms 10552 KiB
03_random_2_03.txt AC 25 ms 9076 KiB
03_random_2_04.txt AC 33 ms 13288 KiB
04_corner_00.txt AC 46 ms 21212 KiB
04_corner_01.txt AC 43 ms 20144 KiB
04_corner_02.txt AC 42 ms 19240 KiB
04_corner_03.txt AC 20 ms 8780 KiB
04_corner_04.txt AC 37 ms 15256 KiB
04_corner_05.txt AC 71 ms 31984 KiB
05_path_00.txt AC 56 ms 29372 KiB
05_path_01.txt AC 29 ms 34064 KiB
06_m_eq_0_00.txt AC 3 ms 6572 KiB
07_n_eq_1_00.txt AC 1 ms 2008 KiB