結果

問題 No.1362 [Zelkova 8th Tune] Black Sheep
ユーザー StrorkisStrorkis
提出日時 2021-01-22 21:57:23
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,999 bytes
コンパイル時間 5,807 ms
コンパイル使用メモリ 136,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 18:52:39
合計ジャッジ時間 7,997 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{BufRead, Write};

struct Lines<B> { b: B, buf: Vec<u8> }
 
impl<B: BufRead> Lines<B> {
    fn next(&mut self) -> &str {
        self.buf.clear();
        self.b.read_until(b'\n', &mut self.buf).ok();
        if self.buf.ends_with(&[b'\n']) {
            self.buf.pop();
            if self.buf.ends_with(&[b'\r']) {
                self.buf.pop();
            }
        }
        std::str::from_utf8(&self.buf).unwrap()
    }
}

macro_rules! parse {
    ($s:expr, Usize1) => (parse!($s, usize) - 1);
    ($s:expr, Bytes) => ($s.as_bytes().to_vec());
    ($s:expr, Chars) => ($s.chars().collect::<Vec<_>>());
    ($s:expr, $t:ty) => ($s.parse::<$t>().unwrap());
}

macro_rules! scan {
    ($iter:expr, ($($t:ident),*)) => (
        ($(scan!($iter, $t)),*)
    );
    ($iter:expr, [$t:ident]) => (
        $iter.map(|s| parse!(s, $t)).collect::<Vec<_>>()
    );
    ($iter:expr, $t:ident) => (
        parse!($iter.next().unwrap(), $t)
    );
}

macro_rules! read {
    ($lines:expr, [$t:tt; $n:expr]) => (
        (0..$n).map(|_| read!($lines, $t)).collect::<Vec<_>>()
    );
    ($lines:expr, $t:tt) => ({
        let iter = &mut $lines.next().split(' ');
        scan!(iter, $t)
    });
}

fn run<B: BufRead, W: Write>(mut lines: Lines<B>, mut writer: W) {
    let s = read!(lines, Bytes);
    let b0 = s.first().unwrap();
    let mut b1 = b0;
    let mut cnt = [0, 0];
    let mut pos = [0, 0];
    for (i, b) in s.iter().enumerate().skip(1) {
        if b == b0 {
            cnt[0] += 1;
            pos[0] = i + 1;
        } else {
            b1 = b;
            cnt[1] += 1;
            pos[1] = i + 1;
        }
    }
    if cnt[0] == 1 {
        writeln!(writer, "{} {}", pos[0], *b0 as char).ok();
    } else {
        writeln!(writer, "{} {}", pos[1], *b1 as char).ok();
    }
}

fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let lines = Lines { b: stdin.lock(), buf: Vec::new() };
    run(lines, std::io::BufWriter::new(stdout.lock()));
}
0