結果
問題 | No.1974 2x2 Flipper |
ユーザー |
|
提出日時 | 2022-06-10 23:49:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 175 ms / 2,000 ms |
コード長 | 1,425 bytes |
コンパイル時間 | 2,581 ms |
コンパイル使用メモリ | 109,924 KB |
実行使用メモリ | 46,088 KB |
最終ジャッジ日時 | 2024-09-21 07:12:04 |
合計ジャッジ時間 | 7,248 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 void Main() { var c = NList; var (h, w) = (c[0], c[1]); var res = new int[h][]; var count = 0; for (var i = 0; i < h; ++i) { res[i] = Enumerable.Repeat(1, w).ToArray(); } if (h % 2 == 0 && w % 2 == 0) { count = h * w; } else if (h % 2 == 0) { for (var i = 0; i < h; ++i) res[i][w - 1] = 0; count = h * (w - 1); } else if (w % 2 == 0) { for (var j = 0; j < w; ++j) res[h - 1][j] = 0; count = (h - 1) * w; } else if (h <= w) { for (var i = 0; i < h; ++i) res[i][i] = 0; for (var i = h; i < w; ++i) res[h - 1][i] = 0; count = (h - 1) * w; } else { for (var i = 0; i < w; ++i) res[i][i] = 0; for (var i = w; i < h; ++i) res[i][w - 1] = 0; count = h * (w - 1); } if (h == 1 || w == 1) count = 0; WriteLine(count); WriteLine(string.Join("\n", res.Select(r => string.Join(" ", r)))); } }