結果
| 問題 |
No.2766 Delicious Multiply Spice
|
| コンテスト | |
| ユーザー |
naut3
|
| 提出日時 | 2024-06-01 01:37:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 961 bytes |
| コンパイル時間 | 17,645 ms |
| コンパイル使用メモリ | 378,884 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-21 03:30:52 |
| 合計ジャッジ時間 | 17,288 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 8 |
| other | AC * 31 |
コンパイルメッセージ
warning: unreachable statement
--> src/main.rs:5:1
|
5 | #[fastout]
| ^^^^^^^^^^ unreachable statement
...
15 | / loop {
16 | | let (rv, log) = q.pop().unwrap();
17 | | let v = rv.0;
18 | |
... |
42 | | }
43 | | }
| |_____- any code following this expression is unreachable
|
= note: `#[warn(unreachable_code)]` on by default
= note: this warning originates in the attribute macro `fastout` (in Nightly builds, run with -Z macro-backtrace for more info)
ソースコード
#![allow(non_snake_case, unused_imports)]
use proconio::{fastout, input, marker::*};
use std::cmp::Reverse;
#[fastout]
fn main() {
input! {
N: usize,
}
let mut q = std::collections::BinaryHeap::new();
q.push((Reverse(N), vec![]));
loop {
let (rv, log) = q.pop().unwrap();
let v = rv.0;
if v == 1 {
let mut l = log.clone();
l.reverse();
println!(
"{}",
l.iter()
.map(|x: &char| x.to_string())
.collect::<Vec<_>>()
.join("")
);
return;
}
if (v - 1) % 2 == 0 {
let mut l = log.clone();
l.push('A');
q.push((Reverse((v - 1) / 2), l));
}
if (v - 1) % 3 == 0 {
let mut l = log.clone();
l.push('B');
q.push((Reverse((v - 1) / 3), l));
}
}
}
naut3