結果

問題 No.2064 Smallest Sequence on Grid
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-03 23:53:16
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,161 bytes
コンパイル時間 983 ms
コンパイル使用メモリ 111,876 KB
実行使用メモリ 45,312 KB
最終ジャッジ日時 2024-04-28 20:11:01
合計ジャッジ時間 9,910 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
19,584 KB
testcase_01 AC 31 ms
19,584 KB
testcase_02 AC 31 ms
19,072 KB
testcase_03 AC 31 ms
19,328 KB
testcase_04 AC 31 ms
19,328 KB
testcase_05 AC 31 ms
19,456 KB
testcase_06 AC 31 ms
19,584 KB
testcase_07 AC 33 ms
19,328 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 293 ms
45,184 KB
testcase_21 AC 298 ms
44,928 KB
testcase_22 AC 295 ms
45,056 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 297 ms
45,056 KB
testcase_27 WA -
testcase_28 AC 234 ms
45,184 KB
testcase_29 AC 253 ms
38,912 KB
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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 string[] SList(int n) => Enumerable.Repeat(0, n).Select(_ => ReadLine()).ToArray();
    static void Main()
    {
        var c = NList;
        var (h, w) = (c[0], c[1]);
        var s = SList(h);
        
        var res = new List<char>();
        res.Add(s[0][0]);
        var prevmin = s[0][0];
        for (var t = 0; t < h + w - 2; ++t)
        {
            var next = new List<(int x, int y)>();
            var min = '{';
            for (var y = Math.Min(t, w - 1); y >= 0; --y)
            {
                var x = t - y;
                if (x >= h) break;
                if (s[x][y] == prevmin)
                {
                    if (x + 1 < h) min = (char)Math.Min(min, s[x + 1][y]);
                    if (y + 1 < w) min = (char)Math.Min(min, s[x][y + 1]);
                }
            }
            res.Add(min);
            prevmin = min;
        }
        WriteLine(string.Concat(res));
    }
}
0