結果

問題 No.1588 Connection
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-13 23:53:26
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 1,538 bytes
コンパイル時間 7,275 ms
コンパイル使用メモリ 158,620 KB
実行使用メモリ 49,956 KB
平均クエリ数 471.19
最終ジャッジ日時 2024-02-13 23:53:39
合計ジャッジ時間 13,520 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
48,676 KB
testcase_01 AC 92 ms
48,676 KB
testcase_02 AC 92 ms
48,676 KB
testcase_03 AC 95 ms
48,676 KB
testcase_04 AC 103 ms
48,676 KB
testcase_05 AC 94 ms
48,676 KB
testcase_06 AC 96 ms
48,676 KB
testcase_07 AC 101 ms
48,676 KB
testcase_08 AC 95 ms
48,676 KB
testcase_09 AC 96 ms
48,676 KB
testcase_10 AC 97 ms
48,676 KB
testcase_11 AC 97 ms
48,676 KB
testcase_12 AC 127 ms
48,804 KB
testcase_13 AC 137 ms
48,804 KB
testcase_14 AC 95 ms
48,676 KB
testcase_15 AC 96 ms
48,676 KB
testcase_16 AC 95 ms
48,676 KB
testcase_17 AC 96 ms
48,676 KB
testcase_18 AC 96 ms
48,804 KB
testcase_19 AC 95 ms
48,804 KB
testcase_20 AC 98 ms
49,700 KB
testcase_21 AC 175 ms
49,956 KB
testcase_22 AC 167 ms
49,956 KB
testcase_23 AC 130 ms
48,932 KB
testcase_24 AC 111 ms
48,804 KB
testcase_25 AC 139 ms
49,828 KB
testcase_26 AC 136 ms
49,828 KB
testcase_27 AC 113 ms
48,932 KB
testcase_28 AC 132 ms
48,804 KB
testcase_29 AC 181 ms
49,060 KB
testcase_30 AC 138 ms
48,932 KB
testcase_31 AC 97 ms
48,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (122 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 int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        n = c[0];
        var map = new int[n][];
        for (var i = 0; i < n; ++i) map[i] = new int[n];
        map[0][0] = 1;
        map[n-1][n-1] = 1;
        WriteLine(DFS(0, 0, map) ? "Yes" : "No");
    }
    static int n;
    static int[][] move = new int[][] { new int[] { -1, 0 }, new int[] { 1, 0 }, new int[] { 0, -1 }, new int[] { 0, 1 } };
    static bool DFS(int i, int j, int[][] map)
    {
        if (i + 1 == n && j + 1 == n) return true;
        foreach (var m in move)
        {
            var ni = i + m[0];
            var nj = j + m[1];
            if (ni < 0 || ni >= n || nj < 0 || nj >= n) continue;
            if (map[ni][nj] == 0)
            {
                WriteLine($"{ni + 1} {nj + 1}");
                var s = ReadLine();
                if (s == "Black") map[ni][nj] = 1;
                else map[ni][nj] = 2;
            }
            if (map[ni][nj] == 1)
            {
                map[ni][nj] = 3;
                if (DFS(ni, nj, map)) return true;
            }
        }
        return false;
    }
}
0