結果
問題 |
No.632 穴埋め門松列
|
ユーザー |
|
提出日時 | 2021-09-15 21:43:19 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 17,717 ms |
コンパイル使用メモリ | 403,496 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 23:08:37 |
合計ジャッジ時間 | 14,583 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
ソースコード
use std::io::Read; fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin=stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } #[allow(dead_code)] fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } fn kado(d: [char; 3]) -> bool { (d[0] < d[1] && d[1] > d[2]) || (d[0] > d[1] && d[1] < d[2]) } fn main() { let c1: char = get(); let c2: char = get(); let c3: char = get(); let c = [c1, c2, c3]; let mut ans = "".to_string(); for i in 0..3 { if c[i] == '?' { let mut d = c; d[i] = '1'; if kado(d) { ans.push('1'); } d[i] = '4'; if kado(d) { ans.push('4'); } } } println!("{}", ans); }