結果
問題 |
No.1010 折って重ねて
|
ユーザー |
|
提出日時 | 2020-03-28 23:16:31 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,279 bytes |
コンパイル時間 | 11,916 ms |
コンパイル使用メモリ | 384,152 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 12:22:39 |
合計ジャッジ時間 | 13,551 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 3 |
ソースコード
use std::collections::{HashSet, VecDeque}; fn main() { let mut xyh: String = String::new(); std::io::stdin().read_line(&mut xyh).ok(); let xyh: Vec<usize> = xyh.trim().split_whitespace().map(|i| i.parse().unwrap()).collect(); let x: u128 = xyh[0] as u128 * 1000; let y: u128 = xyh[1] as u128 * 1000; let h = xyh[2]; let mut cands: VecDeque<(u128, u128, usize, usize)> = VecDeque::new(); let mut used: HashSet<(u128, u128, usize, usize)> = HashSet::new(); let mut target: (u128, u128, usize, usize) = (x, y, h, 0); cands.push_back(target); used.insert(target); while cands.len() > 0 { target = cands.pop_front().unwrap(); if target.0 > target.2 as u128 { let next: (u128, u128, usize, usize) = (target.0 / 2, target.1, target.2 * 2, target.3+1); if !cands.contains(&next) { cands.push_back(next); used.insert(next); } } if target.1 > target.2 as u128 { let next: (u128, u128, usize, usize) = (target.0, target.1 / 2, target.2 * 2, target.3+1); if !cands.contains(&next) { cands.push_back(next); used.insert(next); } } } println!("{}", target.3); }