結果
| 問題 |
No.1885 Flat Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-07 23:25:03 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 790 bytes |
| コンパイル時間 | 16,856 ms |
| コンパイル使用メモリ | 377,372 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 06:32:41 |
| 合計ジャッジ時間 | 17,082 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
コンパイルメッセージ
warning: variable `SIZE` should have a snake case name
--> src/main.rs:17:9
|
17 | let SIZE = y - x + if x == 0 { 1 } else { 0 } + if y == n-1 { 1 } else { 0 } - 1;
| ^^^^ help: convert the identifier to snake case: `size`
|
= note: `#[warn(non_snake_case)]` on by default
ソースコード
const MOD: usize = 998244353;
fn main() {
let mut nxy = String::new();
std::io::stdin().read_line(&mut nxy).ok();
let nxy: Vec<usize> = nxy.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let n = nxy[0];
let x = nxy[1]-1;
let y = nxy[2]-1;
let (x, y) = (x.min(y), x.max(y));
if y-x == 1 && x > 0 && y < n-1 {
println!("0");
return;
}
let SIZE = y - x + if x == 0 { 1 } else { 0 } + if y == n-1 { 1 } else { 0 } - 1;
let mut dp = vec![0usize; SIZE];
dp[0] = 1;
for i in 0..SIZE {
if i+1 < SIZE {
dp[i+1] += dp[i];
dp[i+1] %= MOD;
}
if i+3 < SIZE {
dp[i+3] += dp[i];
dp[i+3] %= MOD;
}
}
println!("{}", dp[SIZE-1]);
}