結果
| 問題 |
No.1169 Row and Column and Diagonal
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 23:01:16 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 938 bytes |
| コンパイル時間 | 14,164 ms |
| コンパイル使用メモリ | 377,572 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 12:25:18 |
| 合計ジャッジ時間 | 15,609 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let mut not_used: Vec<Vec<bool>> = vec![vec![true; n]; n];
for i in 1..n {
let a: Vec<_> = (1..=n).map(|j| {
let ret = if j == i {
i
} else if (n+j-i) % n == i {
n
} else {
(n+j-i) % n
}
;
not_used[j-1][ret-1] = false;
return ret;
})
.map(|j| j.to_string())
.collect();
println!("{}", a.join(" "));
}
println!(
"{}",
not_used.iter().map(|row|
row.iter().enumerate().find(|pair| *pair.1).unwrap().0 + 1usize
)
.map(|i| i.to_string())
.collect::<Vec<String>>()
.join(" ")
);
}