結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー |
|
提出日時 | 2024-07-18 22:47:54 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,489 bytes |
コンパイル時間 | 10,356 ms |
コンパイル使用メモリ | 169,624 KB |
実行使用メモリ | 185,784 KB |
最終ジャッジ日時 | 2024-07-18 22:48:36 |
合計ジャッジ時間 | 35,928 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 11 WA * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (81 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();static int[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => int.Parse(ReadLine())).ToArray();public static void Main(){Solve();}static void Solve(){var c = NList;var (w, h, x) = (c[0], c[1], c[2]);var hoffset = h % 3 == 0 ? 1 : 0;var woffset = w % 3 == 0 ? 1 : 0;var hwidth = h % 3 == 2 ? 2 : 1;var wwidth = w % 3 == 2 ? 2 : 1;var max = hwidth * wwidth * 9;if (x > max){WriteLine(-1);return;}var ans = new int[h][];for (var i = 0; i < ans.Length; ++i) ans[i] = new int[w];var rest = x;for (var i = 0; i < hwidth; ++i) for (var j = 0; j < wwidth; ++j){ans[i + hoffset][j + woffset] = Math.Min(9, rest);rest -= ans[i][j];}for (var i = 0; i < h; ++i) for (var j = 0; j < w; ++j){if (i < 3 && j < 3) continue;ans[i][j] = ans[i % 3][j % 3];}WriteLine(string.Join("\n", ans.Select(ai => string.Join(" ", ai))));}}