結果
| 問題 |
No.481 1から10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-10 22:27:55 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,173 bytes |
| コンパイル時間 | 20,398 ms |
| コンパイル使用メモリ | 379,084 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-28 06:01:22 |
| 合計ジャッジ時間 | 15,238 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 |
コンパイルメッセージ
warning: use of deprecated method `std::error::Error::description`: use the Display impl or to_string()
--> src/main.rs:50:62
|
50 | Err(why) => panic!("error in read_line: {}", why.description()),
| ^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
ソースコード
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;
fn exec() {
let mut sc = Scanner::new();
let a: Vec<usize> = (0..9).map(|_| sc.ne()).collect();
for i in 1..11 {
let mut ok = false;
for &x in &a {
if x == i {
ok = true;
}
}
if !ok {
println!("{}", i);
}
}
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
let builder = thread::Builder::new();
let th = builder.stack_size(DEFAULT_STACK);
let handle = th.spawn(|| { exec(); }).unwrap();
let _ = handle.join();
}
#[allow(dead_code)]
struct Scanner {
stdin: Stdin,
id: usize,
buf: Vec<u8>,
}
#[allow(dead_code)]
impl Scanner {
fn new() -> Scanner {
Scanner {
stdin: io::stdin(),
id: 0,
buf: Vec::new(),
}
}
fn next_line(&mut self) -> Option<String> {
let mut res = String::new();
match self.stdin.read_line(&mut res) {
Ok(0) => return None,
Ok(_) => Some(res),
Err(why) => panic!("error in read_line: {}", why.description()),
}
}
fn next<T: FromStr>(&mut self) -> Option<T> {
while self.buf.len() == 0 {
self.buf = match self.next_line() {
Some(r) => {
self.id = 0;
r.trim().as_bytes().to_owned()
}
None => return None,
};
}
let l = self.id;
assert!(self.buf[l] != b' ');
let n = self.buf.len();
let mut r = l;
while r < n && self.buf[r] != b' ' {
r += 1;
}
let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
Ok(s) => Some(s),
Err(_) => panic!("parse error"),
};
while r < n && self.buf[r] == b' ' {
r += 1;
}
if r == n {
self.buf.clear();
} else {
self.id = r;
}
res
}
fn ne<T: FromStr>(&mut self) -> T {
self.next::<T>().unwrap()
}
}