結果

問題 No.1707 Simple Range Reverse Problem
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-25 22:06:06
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,639 bytes
コンパイル時間 10,764 ms
コンパイル使用メモリ 158,552 KB
実行使用メモリ 180,100 KB
最終ジャッジ日時 2023-12-25 22:06:22
合計ジャッジ時間 14,425 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
32,676 KB
testcase_01 AC 81 ms
32,804 KB
testcase_02 AC 79 ms
32,804 KB
testcase_03 AC 80 ms
32,804 KB
testcase_04 AC 80 ms
32,804 KB
testcase_05 AC 79 ms
32,804 KB
testcase_06 AC 78 ms
32,804 KB
testcase_07 AC 79 ms
32,804 KB
testcase_08 AC 79 ms
32,804 KB
testcase_09 AC 80 ms
32,804 KB
testcase_10 AC 80 ms
32,932 KB
testcase_11 AC 80 ms
32,932 KB
testcase_12 AC 81 ms
32,932 KB
testcase_13 AC 81 ms
32,932 KB
testcase_14 AC 81 ms
32,804 KB
testcase_15 AC 79 ms
32,932 KB
testcase_16 AC 80 ms
32,932 KB
testcase_17 AC 81 ms
32,804 KB
testcase_18 AC 80 ms
180,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new bool[t];
        for (var u = 0; u < t; ++u)
        {
            var n = NN;
            var a = NList;
            ans[u] = Judge(n, a);
        }
        WriteLine(string.Join("\n", ans.Select(f => f ? "Yes" : "No")));
    }
    static bool Judge(int n, int[] a)
    {
        var flength = 0;
        for (var i = 0; i + 1 < a.Length; ++i)
        {
            if (a[i] == 1 && a[i + 1] == n)
            {
                flength = i + 1;
                break;
            }
        }
        if (flength == 0)
        {
            for (var i = 0; i < n; ++i)
            {
                if (a[i] != i + 1 || a[i + n] != i + 1) return false;
            }
        }
        else
        {
            var nl = new List<int>();
            var div = flength / 2 + 1;
            for (var i = 1; i <= div; ++i) nl.Add(i);
            for (var i = div - 1; i > 0; --i) nl.Add(i);
            for (var i = n; i >= div; --i) nl.Add(i);
            for (var i = div + 1; i <= n; ++i) nl.Add(i);
            for (var i = 0; i < a.Length; ++i) if (a[i] != nl[i]) return false;
        }
        return true;
    }
}
0