結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
17,536 KB
testcase_01 AC 25 ms
17,536 KB
testcase_02 AC 26 ms
17,536 KB
testcase_03 WA -
testcase_04 AC 24 ms
17,536 KB
testcase_05 AC 25 ms
17,664 KB
testcase_06 AC 26 ms
17,664 KB
testcase_07 AC 25 ms
17,920 KB
testcase_08 AC 56 ms
17,920 KB
testcase_09 AC 55 ms
17,792 KB
testcase_10 AC 56 ms
17,664 KB
testcase_11 AC 50 ms
17,792 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 24 ms
17,664 KB
testcase_16 AC 25 ms
17,536 KB
testcase_17 AC 24 ms
17,536 KB
testcase_18 AC 55 ms
18,048 KB
testcase_19 AC 53 ms
17,920 KB
testcase_20 AC 25 ms
17,792 KB
testcase_21 AC 25 ms
17,792 KB
testcase_22 WA -
testcase_23 AC 55 ms
17,920 KB
testcase_24 WA -
testcase_25 AC 55 ms
17,920 KB
testcase_26 AC 55 ms
17,920 KB
testcase_27 AC 55 ms
17,664 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 55 ms
17,920 KB
testcase_31 WA -
testcase_32 AC 55 ms
17,536 KB
testcase_33 WA -
testcase_34 AC 56 ms
17,664 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 25 ms
17,664 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 24 ms
17,664 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) {
        //入力
        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++;
                }
            }
        }

        //Console.WriteLine(num_sharp);

        //回答用フラグ
        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 + ")");

                    //平行移動しないものは削除
                    if (i == 0 && j == 0) {
                        continue;
                    }

                    //何回変換作業ができたか(#の個数の半分回できたら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