結果

問題 No.1707 Simple Range Reverse Problem
ユーザー nebukuro09
提出日時 2021-10-15 21:29:18
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 711 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 119,192 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-22 12:48:40
合計ジャッジ時間 1,747 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 998244353;

void solve() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto cnt = new int[](N);
    A[] -= 1;
    foreach (a; A) cnt[a] += 1;
    if (cnt.any!(a => a !=2)) {
        writeln("No");
        return;
    }
    if (A.front != 0) {
        writeln("No");
        return;
    }
    if (A.back != N-1) {
        writeln("No");
        return;
    }
    writeln("Yes");
}

void main() {
    auto T = readln.chomp.to!int;

    while (T--) {
        solve;
    }
}
0