結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー masayamatumasayamatu
提出日時 2022-06-17 22:01:49
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 2,249 bytes
コンパイル時間 10,735 ms
コンパイル使用メモリ 168,808 KB
実行使用メモリ 208,804 KB
最終ジャッジ日時 2024-04-17 13:55:44
合計ジャッジ時間 15,036 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
30,704 KB
testcase_01 AC 58 ms
30,592 KB
testcase_02 AC 58 ms
30,716 KB
testcase_03 AC 57 ms
30,720 KB
testcase_04 AC 53 ms
30,592 KB
testcase_05 WA -
testcase_06 AC 54 ms
30,592 KB
testcase_07 AC 110 ms
47,872 KB
testcase_08 AC 109 ms
55,040 KB
testcase_09 AC 118 ms
55,296 KB
testcase_10 AC 124 ms
55,552 KB
testcase_11 AC 109 ms
55,296 KB
testcase_12 AC 107 ms
51,444 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 101 ms
51,188 KB
testcase_16 AC 59 ms
30,592 KB
testcase_17 AC 58 ms
30,976 KB
testcase_18 WA -
testcase_19 AC 57 ms
30,720 KB
testcase_20 AC 116 ms
50,688 KB
testcase_21 WA -
testcase_22 AC 99 ms
48,384 KB
testcase_23 AC 100 ms
48,512 KB
testcase_24 AC 112 ms
48,256 KB
testcase_25 AC 117 ms
52,084 KB
testcase_26 AC 120 ms
208,804 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /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/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{

    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            int H = HW[0];
            int W = HW[1];
            var grid = new long[H, W];
            for (int i = 0; i < H; i++)
            {
                var read = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
                for (int j = 0; j < W; j++)
                {
                    grid[i, j] = read[j];
                }
            }
            var defeat = new bool[H, W];
            var move = new (int, int)[2] { (0, 1), (1, 0) };
            var q = new Queue<(int, int, long, int)>();
            q.Enqueue((0, 0, grid[0, 0], 0));
            var ok = false;
            while (q.Count > 0)
            {
                var now = q.Dequeue();
                defeat[now.Item1, now.Item2] = true;
                if (now.Item1 == H - 1 && now.Item2 == W - 1 && now.Item3 > grid[H - 1, W - 1])
                {
                    ok = true;
                    break;
                }
                foreach (var i in move)
                {
                    int ny = now.Item1 + i.Item1;
                    int nx = now.Item2 + i.Item2;
                    if (ny < H && ny >= 0 && nx >= 0 && nx < W && !defeat[ny, nx])
                    {
                        defeat[ny, nx] = true;
                        if (now.Item4 == 0 && now.Item3 <= grid[ny, nx])
                        {
                            q.Enqueue((ny, nx, now.Item3, 1));
                        }
                        else if (now.Item3 > grid[ny, nx])
                        {
                            q.Enqueue((ny, nx, now.Item3 + grid[ny, nx], now.Item4));
                        }
                    }
                }

            }
            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}
0