結果
問題 | No.2991 Hypercubic Graph Flow |
ユーザー | akakimidori |
提出日時 | 2024-12-16 20:29:10 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,012 bytes |
コンパイル時間 | 11,057 ms |
コンパイル使用メモリ | 408,616 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-16 20:29:33 |
合計ジャッジ時間 | 12,798 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 0 ms
5,248 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
コンパイルメッセージ
warning: unused import: `std::io::Write` --> src/main.rs:2:5 | 2 | use std::io::Write; | ^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: type alias `Map` is never used --> src/main.rs:4:6 | 4 | type Map<K, V> = BTreeMap<K, V>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Set` is never used --> src/main.rs:5:6 | 5 | type Set<T> = BTreeSet<T>; | ^^^ warning: type alias `Deque` is never used --> src/main.rs:6:6 | 6 | type Deque<T> = VecDeque<T>; | ^^^^^
ソースコード
use std::collections::*; use std::io::Write; type Map<K, V> = BTreeMap<K, V>; type Set<T> = BTreeSet<T>; type Deque<T> = VecDeque<T>; fn main() { input! { n: usize, } if n == 1 { println!("No"); return; } let mut base = if n % 2 == 0 { vec![vec![0]] } else { let mut a = vec![vec![0; 8]; 8]; for &(x, y, v) in [(0, 1, 1), (0, 2, 1), (1, 3, -1), (2, 3, -1)].iter() { a[x][y] = v; a[x + 4][y + 4] = -v; } for i in 0usize..4 { if i.count_ones() == 1 { a[i][i + 4] = 2; } else { a[i][i + 4] = -2; } } for i in 0..8 { for j in (i + 1)..8 { a[j][i] = -a[i][j]; } } a }; while base.len() < (1 << n) { let len = base.len(); let mut next = vec![vec![0; 4 * len]; 4 * len]; for i in 0usize..4 { for j in 0..4 { let x = i * len; let y = j * len; if (i ^ j).count_ones() != 1 { for (next, base) in next[x..(x + len)].iter_mut().zip(base.iter()) { next[y..(y + len)].copy_from_slice(base); } } else if i > j { for p in x..(x + len) { for q in y..(y + len) { next[p][q] = -next[q][p]; } } } else { let v = if (i, j) == (0, 1) || (i, j) == (1, 3) { -1 } else { 1 }; for k in 0..len { next[x + k][y + k] = v; } } } } base = next; } println!("Yes"); for b in base.iter() { use util::*; println!("{}", b.iter().join(" ")); } } // ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[macro_export] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::<Vec<u8>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ---------- mod util { pub trait Join { fn join(self, sep: &str) -> String; } impl<T, I> Join for I where I: Iterator<Item = T>, T: std::fmt::Display, { fn join(self, sep: &str) -> String { let mut s = String::new(); use std::fmt::*; for (i, v) in self.enumerate() { if i > 0 { write!(&mut s, "{}", sep).ok(); } write!(&mut s, "{}", v).ok(); } s } } }