結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 21 ms
18,048 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 21 ms
18,048 KB
testcase_06 WA -
testcase_07 AC 22 ms
17,792 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 20 ms
18,048 KB
testcase_16 WA -
testcase_17 AC 20 ms
18,048 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 21 ms
17,920 KB
testcase_21 AC 21 ms
18,048 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 21 ms
17,792 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 21 ms
18,048 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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