ログインしてください。
提出 #16297186
ソースコード 拡げる
#![allow(clippy::many_single_char_names)]
// ngtio {{{
#[allow(dead_code)]
mod ngtio {
use ::std::collections::VecDeque;
pub struct Buffer {
buf: VecDeque<String>,
}
impl Buffer {
pub fn new() -> Self {
Self {
buf: VecDeque::new(),
}
}
fn load(&mut self) {
while self.buf.is_empty() {
let mut s = String::new();
let length = ::std::io::stdin().read_line(&mut s).unwrap();
if length == 0 {
break;
}
self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));
}
}
pub fn string(&mut self) -> String {
self.load();
self.buf
.pop_front()
.unwrap_or_else(|| panic!("入力が終了したのですが。"))
}
pub fn char(&mut self) -> char {
let string = self.string();
let mut chars = string.chars();
let res = chars.next().unwrap();
assert!(
chars.next().is_none(),
"char で受け取りたいのも山々なのですが、さては 2 文字以上ありますね?"
);
res
}
pub fn read<T: ::std::str::FromStr>(&mut self) -> T
where
<T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
{
self.string()
.parse::<T>()
.expect("Failed to parse the input.")
}
pub fn read_vec<T: ::std::str::FromStr>(&mut self, len: usize) -> Vec<T>
where
<T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
{
(0..len).map(|_| self.read::<T>()).collect()
}
}
macro_rules! define_primitive_reader {
($($ty:tt,)*) => {
impl Buffer {
$(
#[inline]
pub fn $ty(&mut self) -> $ty {
self.read::<$ty>()
}
)*
}
}
}
define_primitive_reader! {
u8, u16, u32, u64, usize,
i8, i16, i32, i64, isize,
}
impl Default for Buffer {
fn default() -> Self {
Self::new()
}
}
}
// }}}
fn main() {
let mut buf = ngtio::Buffer::new();
let ans = if std::iter::repeat_with(|| buf.u32()).take(3).sum::<u32>() <= 4 {
1
} else {
2
};
println!("{}", ans);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - 3 つの整数 (Three Integers) |
| ユーザ | ngtkana |
| 言語 | Rust (1.42.0) |
| 得点 | 100 |
| コード長 | 2610 Byte |
| 結果 | AC |
| 実行時間 | 7 ms |
| メモリ | 2080 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 100 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample-01.txt, sample-02.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, sample-01.txt, sample-02.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01-01.txt | AC | 7 ms | 2052 KiB |
| 01-02.txt | AC | 1 ms | 1988 KiB |
| 01-03.txt | AC | 1 ms | 1948 KiB |
| 01-04.txt | AC | 1 ms | 1888 KiB |
| 01-05.txt | AC | 1 ms | 2080 KiB |
| 01-06.txt | AC | 2 ms | 1892 KiB |
| sample-01.txt | AC | 1 ms | 1956 KiB |
| sample-02.txt | AC | 1 ms | 2056 KiB |