結果

問題 No.179 塗り分け
ユーザー bayashiko_rbayashiko_r
提出日時 2019-01-03 02:28:52
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,181 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 104,960 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-05-02 02:03:55
合計ジャッジ時間 3,695 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
17,792 KB
testcase_01 AC 20 ms
17,664 KB
testcase_02 AC 20 ms
17,920 KB
testcase_03 WA -
testcase_04 AC 20 ms
17,792 KB
testcase_05 AC 20 ms
17,920 KB
testcase_06 AC 20 ms
17,792 KB
testcase_07 AC 20 ms
18,048 KB
testcase_08 AC 98 ms
18,048 KB
testcase_09 AC 102 ms
17,792 KB
testcase_10 AC 22 ms
18,048 KB
testcase_11 AC 23 ms
17,664 KB
testcase_12 AC 110 ms
17,792 KB
testcase_13 AC 22 ms
17,920 KB
testcase_14 WA -
testcase_15 AC 22 ms
17,920 KB
testcase_16 AC 21 ms
17,920 KB
testcase_17 AC 21 ms
17,664 KB
testcase_18 AC 23 ms
17,792 KB
testcase_19 AC 23 ms
17,920 KB
testcase_20 AC 20 ms
17,792 KB
testcase_21 AC 21 ms
17,920 KB
testcase_22 AC 100 ms
17,920 KB
testcase_23 AC 22 ms
17,920 KB
testcase_24 AC 102 ms
17,920 KB
testcase_25 AC 23 ms
18,048 KB
testcase_26 AC 63 ms
17,920 KB
testcase_27 AC 118 ms
17,664 KB
testcase_28 AC 90 ms
18,048 KB
testcase_29 AC 142 ms
17,792 KB
testcase_30 AC 43 ms
17,664 KB
testcase_31 WA -
testcase_32 AC 71 ms
17,920 KB
testcase_33 WA -
testcase_34 AC 50 ms
17,792 KB
testcase_35 AC 131 ms
18,048 KB
testcase_36 AC 20 ms
17,664 KB
testcase_37 AC 20 ms
17,920 KB
testcase_38 AC 21 ms
17,792 KB
testcase_39 AC 21 ms
17,792 KB
testcase_40 AC 20 ms
17,792 KB
testcase_41 AC 21 ms
17,664 KB
testcase_42 AC 19 ms
17,792 KB
testcase_43 AC 21 ms
17,792 KB
testcase_44 AC 31 ms
17,920 KB
testcase_45 AC 21 ms
17,664 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) {
        #region

        //入力
        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];
                kari[i, j] = field[i, j];
                if (row[i][j] == '#') {
                    num_sharp++;
                }
            }
        }

        //Console.WriteLine(num_sharp);

        #endregion //ここは大丈夫

        //回答用フラグ
        bool flg = false;

        if (num_sharp % 2 == 1 || num_sharp == 0) {
            //#の個数が奇数の時(もしくは0の時)は、絶対にペアは作れない
            flg = false;
        } else {


            //計算実行
            for (int i = 0; i < W; i++) {
                for (int j = -H + 1; j < H; j++) {
                    //Console.WriteLine("●(i, j) = (" + i + "," + j + ")");

                    //毎回リセットする
                    int counter = 0;
                    for (int an = 0; an < H; an++) {
                        for (int b = 0; b < W; b++) {
                            kari[an, b] = field[an, b];
                        }
                    }

                    //平行移動しないものは飛ばす
                    if (i == 0 && j == 0) {
                        continue;
                    }
                  
                    //kariのR-Area全てのcharについて、調査する
                    if (j >= 0) {
                        for (int tate = j; tate < H; tate++) {
                            
                            for (int yoko = 0; yoko < W - i; yoko++) {
                                //Console.WriteLine("(tate, yoko) = (" + tate + "," + yoko + ")");
                                if (kari[tate, yoko] == '#') {
                                    //Console.WriteLine("a");
                                    if (kari[tate, yoko] == kari[tate - j, yoko + i]) {
                                        counter++;
                                        //Console.WriteLine("b");
                                        kari[tate - j, yoko + i] = '.';
                                    }
                                    //Console.WriteLine(counter);
                                }
                            }
                        }
                    } else if (j < 0) {
                        for (int tate = 0; tate < H + j; tate++) {
                            for (int yoko = 0; yoko < W - i; yoko++) {
                                //Console.WriteLine("(tate, yoko) = (" + tate + "," + yoko + ")");
                                if (kari[tate, yoko] == '#') {
                                    //Console.WriteLine("a");
                                    if (kari[tate, yoko] == kari[tate - j, yoko + i]) {
                                        counter++;
                                        //Console.WriteLine("b");
                                        kari[tate - j, yoko + i] = '.';
                                    }
                                    //Console.WriteLine(counter);
                                }
                            }
                        }
                    }
                    //Console.WriteLine(counter);

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

        LABEL:

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