結果
| 問題 |
No.998 Four Integers
|
| コンテスト | |
| ユーザー |
cotton_fn_
|
| 提出日時 | 2020-02-29 10:41:20 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 2,750 bytes |
| コンパイル時間 | 13,379 ms |
| コンパイル使用メモリ | 380,060 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 23:14:52 |
| 合計ジャッジ時間 | 13,358 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
#![allow(unused)]
use std::{
io::{self, prelude::*},
mem::{replace, swap},
};
pub struct Input<R> {
src: R,
buf: Vec<u8>,
pos: usize,
}
impl<R: BufRead> Input<R> {
pub fn new(src: R) -> Self {
Self {
src,
buf: Vec::new(),
pos: 0,
}
}
pub fn input_raw(&mut self) -> &[u8] {
loop {
self.advance_while(|b| b.is_ascii_whitespace());
if self.pos == self.buf.len() {
self.buf.clear();
self.src.read_until(b'\n', &mut self.buf).expect("io error");
self.pos = 0;
} else {
break;
}
}
let start = self.pos;
self.advance_while(|b| !b.is_ascii_whitespace());
&self.buf[start..self.pos]
}
fn advance_while(&mut self, f: impl Fn(u8) -> bool) {
while self.buf.get(self.pos).map_or(false, |b| f(*b)) {
self.pos += 1;
}
}
pub fn input<T: InputParse>(&mut self) -> T {
T::input(self)
}
}
pub trait InputParse {
fn input<R: BufRead>(input: &mut Input<R>) -> Self;
}
macro_rules! input_from_str_impls {
{ $($T:ty)* } => {
$(impl InputParse for $T {
fn input<R: BufRead>(input: &mut Input<R>) -> Self {
String::from_utf8_lossy(input.input_raw())
.parse()
.expect("parse error")
}
})*
};
}
macro_rules! input_tuple_impls {
{ $(($($T:ident),+))* } => {
$(impl<$($T: InputParse),+> InputParse for ($($T),+) {
fn input<R: BufRead>(input: &mut Input<R>) -> Self {
($(input.input::<$T>()),+)
}
})*
};
}
input_from_str_impls! {
String char bool f32 f64
isize i8 i16 i32 i64 i128
usize u8 u16 u32 u64 u128
}
input_tuple_impls! {
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
}
macro_rules! output {
($out:expr, $($args:expr),*) => {
$out.write_fmt(format_args!($($args),*))
};
}
macro_rules! outputln {
($out:expr, $($args:expr),*) => {
output!($out, $($args),*);
outputln!($out);
};
($out:expr) => {
output!($out, "\n");
};
}
fn main() {
let stdin = io::stdin();
let mut input = Input::new(stdin.lock());
let stdout = io::stdout();
let mut out = io::BufWriter::new(stdout.lock());
let mut a: Vec<i32> = (0..4).map(|_| input.input()).collect();
a.sort();
let f = || {
for i in 0..3 {
if a[i] + 1 != a[i + 1] { return false; }
}
return true;
};
outputln!(&mut out, "{}", if f() { "Yes" } else { "No" });
}
cotton_fn_