結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-23 15:42:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 566 bytes |
| コンパイル時間 | 13,651 ms |
| コンパイル使用メモリ | 384,004 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-20 18:51:23 |
| 合計ジャッジ時間 | 15,138 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 RE * 19 |
ソースコード
fn main() {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
let n: usize = s.trim().parse().unwrap();
let (mut x, mut y, mut p, mut q) = (0i8, 0i8, 1i8, 0i8);
let mut a = vec![0; n * n];
for i in 1..=n * n {
a[(x + y * n as i8) as usize] = i;
if x + p >= n as i8
|| y + q >= n as i8
|| a[(x + p + (y + q) * n as i8) as usize] != 0
{
(p, q) = (-q, p);
}
x += p;
y += q;
}
a.chunks(n).for_each(|r| {
println!(
"{}",
r.iter()
.map(|&x| format!("{:03}", x))
.collect::<Vec<_>>()
.join(" ")
)
});
}