結果

問題 No.1707 Simple Range Reverse Problem
ユーザー akakimidoriakakimidori
提出日時 2021-10-15 21:24:24
言語 Rust
(1.72.1)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,867 bytes
コンパイル時間 4,086 ms
コンパイル使用メモリ 167,784 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 20:00:09
合計ジャッジ時間 4,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 4 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std::str::FromStr;
    pub struct Scanner<'a> {
        it: std::str::SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace(),
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            self.it.next().unwrap().parse::<T>().ok().unwrap()
        }
        pub fn next_bytes(&mut self) -> Vec<u8> {
            self.it.next().unwrap().bytes().collect()
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.it.next().unwrap().chars().collect()
        }
        pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
            (0..len).map(|_| self.next()).collect()
        }
    }
}
// ---------- end scannner ----------

use std::io::Write;

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut sc = scanner::Scanner::new(&s);
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    run(&mut sc, &mut out);
}

fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) {
    let t: u32 = sc.next();
    for _ in 0..t {
        let n: usize = sc.next();
        let a: Vec<usize> = sc.next_vec(2 * n);
        let b = (1..=n).cycle().take(2 * n).collect::<Vec<_>>();
        let mut ans = a == b;
        for i in 0..(2 * n) {
            for j in 0..i {
                if b[i] == b[j] {
                    let mut b = b.clone();
                    b[j..=i].reverse();
                    ans |= a == b;
                }
            }
        }
        if ans {
            writeln!(out, "Yes").ok();
        } else {
            writeln!(out, "No").ok();
        }
    }
}
0