結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-13 23:53:26 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 1,538 bytes |
| コンパイル時間 | 7,978 ms |
| コンパイル使用メモリ | 167,544 KB |
| 実行使用メモリ | 48,344 KB |
| 平均クエリ数 | 471.19 |
| 最終ジャッジ日時 | 2024-09-28 18:41:18 |
| 合計ジャッジ時間 | 11,946 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (97 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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;
}
}