結果

問題 No.1668 Grayscale
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-05 11:23:59
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 1,167 ms / 4,000 ms
コード長 1,598 bytes
コンパイル時間 7,817 ms
コンパイル使用メモリ 158,544 KB
実行使用メモリ 180,360 KB
最終ジャッジ日時 2024-01-05 11:24:24
合計ジャッジ時間 15,211 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
32,932 KB
testcase_01 AC 83 ms
32,932 KB
testcase_02 AC 84 ms
32,932 KB
testcase_03 AC 82 ms
32,804 KB
testcase_04 AC 84 ms
32,932 KB
testcase_05 AC 107 ms
32,804 KB
testcase_06 AC 636 ms
154,544 KB
testcase_07 AC 602 ms
154,460 KB
testcase_08 AC 182 ms
59,456 KB
testcase_09 AC 1,167 ms
154,668 KB
testcase_10 AC 318 ms
79,404 KB
testcase_11 AC 92 ms
33,316 KB
testcase_12 AC 91 ms
33,444 KB
testcase_13 AC 124 ms
45,220 KB
testcase_14 AC 230 ms
65,656 KB
testcase_15 AC 168 ms
54,820 KB
testcase_16 AC 123 ms
47,780 KB
testcase_17 AC 114 ms
41,124 KB
testcase_18 AC 86 ms
32,932 KB
testcase_19 AC 86 ms
32,932 KB
testcase_20 AC 88 ms
33,444 KB
testcase_21 AC 87 ms
33,444 KB
testcase_22 AC 84 ms
32,932 KB
testcase_23 AC 86 ms
180,360 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (111 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;
        var (h, w, n) = (c[0], c[1], c[2]);
        var map = NArr(h);
        var tree = new List<(int to, int len)>[n];
        for (var i = 0; i < tree.Length; ++i) tree[i] = new List<(int to, int len)>();
        for (var i = 0; i + 1 < n; ++i) tree[i].Add((i + 1, 0));
        for (var i = 0; i < h; ++i) for (var j = 0; j + 1 < w; ++j)
        {
            if (map[i][j] < map[i][j + 1]) tree[map[i][j] - 1].Add((map[i][j + 1] - 1, 1));
            else if (map[i][j] > map[i][j + 1]) tree[map[i][j + 1] - 1].Add((map[i][j] - 1, 1));
        }
        for (var i = 0; i + 1 < h; ++i) for (var j = 0; j < w; ++j)
        {
            if (map[i][j] < map[i + 1][j]) tree[map[i][j] - 1].Add((map[i + 1][j] - 1, 1));
            else if (map[i][j] > map[i + 1][j]) tree[map[i + 1][j] - 1].Add((map[i][j] - 1, 1));
        }
        var len = new int[n];
        for (var i = 0; i + 1 < n; ++i)
        {
            foreach (var next in tree[i])
            {
                len[next.to] = Math.Max(len[next.to], len[i] + next.len);
            }
        }
        WriteLine(new HashSet<int>(len).Count);
    }
}
0