結果
| 問題 | No.1707 Simple Range Reverse Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-17 02:28:25 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,400 bytes |
| 記録 | |
| コンパイル時間 | 13,375 ms |
| コンパイル使用メモリ | 377,544 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 19:32:10 |
| 合計ジャッジ時間 | 14,610 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 13 |
ソースコード
use std::collections::VecDeque;
fn solve() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let mut a = String::new();
std::io::stdin().read_line(&mut a).ok();
let mut a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let mut not_checked = (1..=n).collect::<VecDeque<usize>>();
while not_checked.len() > 1 {
let front = not_checked[0];
let back = not_checked[not_checked.len()-1];
if a[front-1] != front || a[back+n-1] != back {
break;
}
if a[front+n-1] == a[front-1] && a[back-1] == a[back+n-1] {
not_checked.pop_back();
not_checked.pop_front();
} else if a[front+n-1] != a[front-1] && a[back-1] != a[back+n-1] {
break;
} else if a[front+n-1] != a[front-1] {
a[back-1..=back+n-1].reverse();
not_checked.pop_back();
} else {
a[front-1..=front+n-1].reverse();
not_checked.pop_front();
}
}
if (0..2*n).filter(|&i| (i%n)+1 != a[i]).count() == 0 {
println!("Yes");
} else {
println!("No");
}
}
fn main() {
let mut t = String::new();
std::io::stdin().read_line(&mut t).ok();
let t: usize = t.trim().parse().unwrap();
for _ in 0..t {
solve();
}
}