結果

問題 No.2052 Indegree
ユーザー titia
提出日時 2022-09-05 04:39:41
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 17,304 ms
コンパイル使用メモリ 379,200 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 13:57:47
合計ジャッジ時間 18,566 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `a`
  --> src/main.rs:16:14
   |
16 |         let (a, b): (usize, usize) = {
   |              ^ help: if this is intentional, prefix it with an underscore: `_a`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

fn main() {
    let (n, m): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),

        )
    };

    let mut indeg:Vec<usize>=vec![0;n+1];

    for _ in 0..m{
        let (a, b): (usize, usize) = {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
    
            )
        };

        indeg[b]+=1;
    }

    let mut ans=0;

    for i in 1..n+1{
        if indeg[i]==0{
            ans+=1;
        }
    }

    println!("{}",ans);

}
0