結果
問題 |
No.3287 Golden Ring
|
ユーザー |
|
提出日時 | 2025-10-03 21:57:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,093 bytes |
コンパイル時間 | 24,416 ms |
コンパイル使用メモリ | 402,056 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-03 21:57:29 |
合計ジャッジ時間 | 14,076 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
use proconio::input; fn main() { input! { n: usize, } match solve(n) { Some(aa) => println!( "Yes\n{}", aa.iter() .map(|a| a.to_string()) .collect::<Vec<String>>() .join(" ") ), None => println!("No"), } } fn solve(n: usize) -> Option<Vec<usize>> { if n == 2 { return None; } let mut aa = (1..=n).collect::<Vec<usize>>(); if n % 2 == 0 { aa.swap(n - 2, n - 1); } Some(aa) } #[cfg(test)] mod tests { use itertools::Itertools; fn round_robin(n: usize) -> Option<Vec<usize>> { (1..=n).permutations(n).find(|perm| { perm.iter() .circular_tuple_windows() .map(|(a1, a2)| a1 + a2) .all_unique() }) } #[test] fn test() { for n in 2..=8 { match round_robin(n) { Some(aa) => println!("{n}: {}", aa.iter().join(" ")), None => println!("{n}: No Solution"), } } } }