結果

問題 No.179 塗り分け
ユーザー bayashiko_rbayashiko_r
提出日時 2019-01-02 23:28:42
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,926 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 111,112 KB
実行使用メモリ 27,916 KB
最終ジャッジ日時 2024-05-01 19:16:17
合計ジャッジ時間 3,461 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
17,792 KB
testcase_01 AC 22 ms
17,536 KB
testcase_02 AC 22 ms
17,920 KB
testcase_03 WA -
testcase_04 AC 21 ms
17,664 KB
testcase_05 AC 21 ms
17,536 KB
testcase_06 AC 21 ms
17,792 KB
testcase_07 WA -
testcase_08 AC 45 ms
17,664 KB
testcase_09 AC 46 ms
18,048 KB
testcase_10 AC 48 ms
17,920 KB
testcase_11 AC 44 ms
17,664 KB
testcase_12 WA -
testcase_13 AC 21 ms
17,792 KB
testcase_14 AC 20 ms
17,792 KB
testcase_15 AC 20 ms
17,536 KB
testcase_16 WA -
testcase_17 AC 20 ms
17,536 KB
testcase_18 AC 47 ms
17,664 KB
testcase_19 AC 46 ms
17,536 KB
testcase_20 AC 22 ms
17,792 KB
testcase_21 AC 21 ms
17,792 KB
testcase_22 WA -
testcase_23 AC 49 ms
17,664 KB
testcase_24 WA -
testcase_25 AC 52 ms
17,920 KB
testcase_26 AC 50 ms
17,664 KB
testcase_27 AC 48 ms
17,664 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 47 ms
17,920 KB
testcase_31 WA -
testcase_32 AC 46 ms
18,048 KB
testcase_33 WA -
testcase_34 AC 47 ms
17,792 KB
testcase_35 WA -
testcase_36 AC 22 ms
17,536 KB
testcase_37 AC 21 ms
17,792 KB
testcase_38 WA -
testcase_39 AC 23 ms
17,536 KB
testcase_40 AC 23 ms
17,792 KB
testcase_41 AC 22 ms
17,920 KB
testcase_42 AC 23 ms
17,536 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 22 ms
17,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program {
    static void Main(string[] args) {
        //入力
        string a = Console.ReadLine();
        int H = int.Parse(a.Split(' ')[0]);
        int W = int.Parse(a.Split(' ')[1]);

        string[] row = new string[H];

        for (int i = 0; i < H; i++) {
            row[i] = Console.ReadLine();
        }

        //#を数える用の変数
        int num_sharp = 0;

        //全マスを二行に列の配列として扱う
        char[,] field = new char[H, W];
        //置き換え用
        char[,] kari = new char[H, W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                field[i, j] = row[i][j];
                if (row[i][j] == '#') {
                    num_sharp++;
                }
            }
        }
        //回答用フラグ
        bool flg = false;

        if (num_sharp % 2 == 1) {
            //#の個数が奇数の時は、絶対にペアは作れない
            flg = false;
        } else {
            //計算実行
            for (int i = 0; i < H; i++) {
                for (int j = -W + 1; j < W; j++) {
                    //平行移動しないものは削除
                    if (i == 0 && j == 0) {
                        break;
                    }

                    //何回変換作業ができたか(#の個数の半分回できたらflgはtrueになる)
                    //毎回リセットする
                    int counter = 0;
                    kari = field;
                    
                    //kariのR-Area全てのcharについて、調査する
                    if (j >= 0) {
                        for (int tate = j; tate < H; tate++) {
                            for (int yoko = 0; yoko < W - i; yoko++) {
                                if (kari[tate, yoko] == kari[tate - j, yoko + i]) {
                                    counter++;
                                    kari[tate - j, yoko + i] = ' ';
                                }
                            }
                        }
                    } else {
                        for (int tate = 0; tate < H + j; tate++) {
                            for (int yoko = 0; yoko < W - i; yoko++) {
                                if (kari[tate, yoko] == kari[tate - j, yoko + i]) {
                                    counter++;
                                    kari[tate - j, yoko + i] = ' ';
                                }
                            }
                        }
                    }
                    



                    //flgの判定
                    if (counter == num_sharp / 2) {
                        flg = true;
                    }
                }
            }

        }

        //出力
        if (flg) {
            Console.WriteLine("YES");
        } else {
            Console.WriteLine("NO");
        }
        

    }
}
0