結果
問題 | No.2098 [Cherry Alpha *] Introduction |
ユーザー |
![]() |
提出日時 | 2024-04-25 18:16:46 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,712 bytes |
コンパイル時間 | 12,963 ms |
コンパイル使用メモリ | 379,548 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 05:43:41 |
合計ジャッジ時間 | 13,931 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
ソースコード
#![allow(non_snake_case, unused_imports, unused_must_use)]use std::io::{self, prelude::*};use std::str;fn main() {let (stdin, stdout) = (io::stdin(), io::stdout());let mut scan = Scanner::new(stdin.lock());let mut out = io::BufWriter::new(stdout.lock());macro_rules! input {($T: ty) => {scan.token::<$T>()};($T: ty, $N: expr) => {(0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>()};}let S = input!(String).chars().collect::<Vec<_>>()[0];match S {'Z' => {writeln!(out, "1st");}'B' => {writeln!(out, "2nd");}'S' => {writeln!(out, "3rd");}'E' => {writeln!(out, "4th");}_ => {writeln!(out, "Alpha");}}}struct Scanner<R> {reader: R,buf_str: Vec<u8>,buf_iter: str::SplitWhitespace<'static>,}impl<R: BufRead> Scanner<R> {fn new(reader: R) -> Self {Self {reader,buf_str: vec![],buf_iter: "".split_whitespace(),}}fn token<T: str::FromStr>(&mut self) -> T {loop {if let Some(token) = self.buf_iter.next() {return token.parse().ok().expect("Failed parse");}self.buf_str.clear();self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");self.buf_iter = unsafe {let slice = str::from_utf8_unchecked(&self.buf_str);std::mem::transmute(slice.split_whitespace())}}}}