結果

問題 No.1707 Simple Range Reverse Problem
ユーザー tonyu0tonyu0
提出日時 2021-10-15 23:17:54
言語 Rust
(1.72.1)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 170,088 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 21:02:15
合計ジャッジ時間 1,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 9 ms
4,348 KB
testcase_10 AC 10 ms
4,348 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 11 ms
4,348 KB
testcase_13 AC 12 ms
4,348 KB
testcase_14 AC 8 ms
4,348 KB
testcase_15 AC 12 ms
4,348 KB
testcase_16 AC 10 ms
4,348 KB
testcase_17 AC 9 ms
4,348 KB
testcase_18 AC 12 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let t: usize = itr.next().unwrap().parse().unwrap();
    for _ in 0..t {
        let n: usize = itr.next().unwrap().parse().unwrap();
        let a: Vec<usize> = (0..n * 2)
            .map(|_| itr.next().unwrap().parse().unwrap())
            .collect();
        let mut ans = false;
        let mut ok = true;
        for i in 0..n * 2 {
            ok &= a[i] == i % n + 1;
        }
        ans |= ok;

        for i in 0..n {
            let mut ko = true;
            let mut b = Vec::new();
            for j in 0..i {
                b.push(j % n + 1);
            }
            for j in (i..i + n + 1).rev() {
                b.push(j % n + 1);
            }
            for j in i + n + 1..n * 2 {
                b.push(j % n + 1);
            }
            for j in 0..n * 2 {
                ko &= b[j] == a[j];
            }
            ans |= ko;
        }
        if ans {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}
0