京都大学プログラミングコンテスト2015

Submission #3975936

Source codeソースコード

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        strs: [String; n],
    }

    for i in strs {
        let mut edges: Vec<_> = i.match_indices("tokyo").map(|x| (x.0, x.0 + 4)).collect();
        edges.append(&mut i.match_indices("kyoto").map(|x| (x.0, x.0 + 4)).collect());
        edges.sort_by(|a, b| a.0.cmp(&b.0));

        let mut cnt = 0;
        let mut previous = 0;
        for (j, k) in edges {
            if previous < j {
                cnt += 1;
                previous = k;
            }
        }
        println!("{}", cnt);
    }
}

Submission

Task問題 A - 東京都
User nameユーザ名 いかずち
Created time投稿日時
Language言語 Rust (1.15.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1800 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
--> ./Main.rs:23:13
|
23 | let mut $var = read_value!($iter, $t);
| ^
...
51 | input! {
| _____- starting here...
52 | | n: usize,
53 | | strs: [String; n],
54 | | }
| |_____- ...ending here: in this macro invocation

warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
--> ./Main.rs:23:13
|
23 | let mut $var = read_value!($iter, $t);
| ^
...
51 | input! {
| _____- starting here...
52 | | n: usize,
53 | | strs: [String; n],
54 | | }
| |_____- ...ending here: in this macro invocation

Test case

Set

Set name Score得点 / Max score Cases
All 0 / 100 10_random_to_kyo.txt,20_noised_tokyoto.txt,99_teuchi.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
10_random_to_kyo.txt WA
20_noised_tokyoto.txt WA
99_teuchi.txt WA