結果

問題 No.1588 Connection
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-13 23:48:28
言語 C#
(.NET 8.0.203)
結果
MLE  
実行時間 -
コード長 1,504 bytes
コンパイル時間 7,753 ms
コンパイル使用メモリ 156,816 KB
実行使用メモリ 843,812 KB
平均クエリ数 0.09
最終ジャッジ日時 2024-02-13 23:48:39
合計ジャッジ時間 11,046 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
48,676 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /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 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)
            {
                if (DFS(ni, nj, map)) return true;
            }
        }
        return false;
    }
}
0