結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー しらゆきしらゆき
提出日時 2016-01-05 07:53:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,812 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 109,572 KB
実行使用メモリ 25,260 KB
最終ジャッジ日時 2023-10-19 15:13:46
合計ジャッジ時間 3,757 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 27 ms
25,256 KB
testcase_02 AC 27 ms
25,256 KB
testcase_03 AC 27 ms
25,256 KB
testcase_04 AC 28 ms
25,256 KB
testcase_05 AC 27 ms
25,256 KB
testcase_06 AC 26 ms
25,256 KB
testcase_07 AC 27 ms
25,256 KB
testcase_08 AC 29 ms
25,256 KB
testcase_09 AC 27 ms
25,256 KB
testcase_10 AC 28 ms
25,256 KB
testcase_11 AC 27 ms
25,256 KB
testcase_12 AC 28 ms
25,256 KB
testcase_13 AC 28 ms
25,256 KB
testcase_14 AC 29 ms
25,256 KB
testcase_15 AC 28 ms
25,256 KB
testcase_16 AC 28 ms
25,256 KB
testcase_17 AC 27 ms
25,256 KB
testcase_18 AC 27 ms
25,256 KB
testcase_19 AC 27 ms
25,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var a = new int[16];
        for(int i = 0; i < 4; i++)
        {
            var tmp = ria(4);
            for(int j = 0; j < 4; j++)
            {
                a[i * 4 + j] = tmp[j];
            }
        }

        int inv = 0;
        var ans = "Yes";
        for(int i = 0; i < 16; i++)
        {
            for(int j= i; j < 16; j++)
            {
                if (a[i] > a[j] && a[j] != 0) inv++;
            }
            if (a[i] == 0) inv += (15 - i) / 4;
            if (a[i] != 0 && !(a[i] == i + 2 || a[i] == i + 1 || a[i] == i || a[i] == i + 5 || a[i] == i - 3)) ans = "No";
        }

        if (inv % 2 == 1) ans = "No";

        Console.WriteLine(ans);
    }

    #region Scan
    static int ri() { return int.Parse(Console.ReadLine()); }
    static long rl() { return long.Parse(Console.ReadLine()); }
    static double rd() { return double.Parse(Console.ReadLine()); }
    static string rs() { return Console.ReadLine(); }
    static int[] ria(int n) { return Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); }
    static long[] rla(int n) { return Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
    static double[] rda(int n) { return Console.ReadLine().Trim().Split().Select(double.Parse).ToArray(); }
    static string[] rsa(int n) { return Console.ReadLine().Trim().Split(); }
    static void mul(out int a, out int b) { var arr = ria(2); a = arr[0]; b = arr[1]; }
    public void mul(out int a, out int b, out int c) { var arr = ria(3); a = arr[0]; b = arr[1]; c = arr[2]; }
    public void mul(out int a, out int b, out int c, out int d) { var arr = ria(4); a = arr[0]; b = arr[1]; c = arr[2]; d = arr[3]; }
    #endregion
}
0