結果

問題 No.1412 Super Ryuo
ユーザー StrorkisStrorkis
提出日時 2021-02-28 21:25:17
言語 Rust
(1.77.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,677 bytes
コンパイル時間 9,911 ms
コンパイル使用メモリ 400,936 KB
最終ジャッジ日時 2024-04-27 03:41:05
合計ジャッジ時間 10,462 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
error: format argument must be a string literal
 --> src/main.rs:8:34
  |
8 |                 Err(e) => panic!(e), 
  |                                  ^
  |
help: you might be missing a string literal to format with
  |
8 |                 Err(e) => panic!("{}", e), 
  |                                  +++++

error: could not compile `main` (bin "main") due to 1 previous error

ソースコード

diff #

mod io {
    pub fn scan<R: std::io::BufRead>(r: &mut R) -> Vec<u8> {
        let mut res = Vec::new();
        loop {
            let buf = match r.fill_buf() {
                Ok(buf) => buf,
                Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue,
                Err(e) => panic!(e), 
            };
            let (done, used, buf) = {
                match buf.iter().position(u8::is_ascii_whitespace) {
                    Some(i) => (i > 0 || res.len() > 0, i + 1, &buf[..i]),
                    None => (buf.is_empty(), buf.len(), buf),
                }
            };
            res.extend_from_slice(buf);
            r.consume(used);
            if done { return res; }
        }
    }
}

#[allow(unused_macros)]
fn run<R: std::io::BufRead, W: std::io::Write>(reader: &mut R, writer: &mut W) {
    macro_rules! scan {
        ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::<Vec<_>>());
        (($($t:tt),*)) => (($(scan!($t)),*));
        ([u8]) => (io::scan(reader));
        (String) => (unsafe { String::from_utf8_unchecked(scan!([u8])) });
        ($t:ty) => (scan!(String).parse::<$t>().unwrap());
    }
    macro_rules! println {
        ($($arg:tt)*) => (writeln!(writer, $($arg)*).ok());
    }

    let (a, b, c, d) = scan!((i64, i64, i64, i64));

    if a == c || b == d || (a - c).abs() + (b - d).abs() <= 3 {
        println!("1");
    } else {
        println!("2");
    }
}

fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());
    run(&mut reader, &mut writer);
}
0