結果

問題 No.1434 Make Maze
ユーザー kakel-san
提出日時 2024-07-10 21:28:21
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,928 bytes
コンパイル時間 8,587 ms
コンパイル使用メモリ 166,508 KB
実行使用メモリ 187,976 KB
最終ジャッジ日時 2024-07-10 21:28:38
合計ジャッジ時間 16,395 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (107 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 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, x) = (c[0], c[1], c[2]);
        if (x < h + w - 2 || (h + w - 2 - x) % 4 != 0)
        {
            WriteLine(-1);
            return;
        }
        var ans = new bool[h][];
        for (var i = 0; i < h; ++i)
        {
            ans[i] = new bool[w];
            if (i % 2 == 1) for (var j = 0; j + 1 < w; ++j) ans[i][j] = true;
        }
        var rest = x - h - w + 2;
        for (var i = 2; i + 2 < h; i += 4)
        {
            if (rest == 0) break;
            for (var j = w - 3; j >= 0; j -= 2)
            {
                if (rest == 0) break;
                ans[i][j + 1] = false;
                ans[i + 1][j] = false;
                ans[i + 1][j + 2] = true;
                ans[i + 2][j + 1] = false;
                rest -= 4;
            }
        }
        if (h % 4 == 3) for (var j = 0; j + 3 < w; j += 4)
        {
            if (rest == 0) break;
            ans[h - 3][j + 1] = true;
            ans[h - 2][j] = false;
            ans[h - 2][j + 2] = false;
            ans[h - 1][j + 1] = false;
            if (j + 3 < w)
            {
                ans[h - 3][j + 3] = false;
                ans[h - 1][j + 3] = true;
            }
            rest -= 4;
        }
        if (rest > 0)
        {
            WriteLine(-1);
            return;
        }
        WriteLine(string.Join("\n", ans.Select(ai => string.Concat(ai.Select(m => m ? '#' : '.')))));
    }
}
0