結果

問題 No.640 76本のトロンボーン
ユーザー htensaihtensai
提出日時 2019-12-31 10:39:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,824 bytes
コンパイル時間 1,914 ms
コンパイル使用メモリ 77,220 KB
実行使用メモリ 55,824 KB
最終ジャッジ日時 2024-04-29 00:53:13
合計ジャッジ時間 4,745 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
53,964 KB
testcase_01 AC 100 ms
52,996 KB
testcase_02 AC 100 ms
54,216 KB
testcase_03 WA -
testcase_04 AC 112 ms
54,008 KB
testcase_05 AC 113 ms
54,120 KB
testcase_06 WA -
testcase_07 AC 131 ms
54,280 KB
testcase_08 AC 130 ms
53,988 KB
testcase_09 AC 136 ms
54,256 KB
testcase_10 AC 133 ms
54,052 KB
testcase_11 AC 139 ms
54,464 KB
testcase_12 AC 134 ms
53,728 KB
testcase_13 WA -
testcase_14 AC 125 ms
53,940 KB
testcase_15 AC 111 ms
54,224 KB
testcase_16 AC 101 ms
52,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[][] field = new char[n][];
        boolean[][] horArr = new boolean[3][n];
        for (int i = 0; i < n; i++) {
            field[i] = sc.next().toCharArray();
            int count = 0;
            for (int j = 0; j < n; j++) {
                if (field[i][j] == '#') {
                    count++;
                }
            }
            if (count == 1) {
                if (field[i][0] == '#') {
                    horArr[1][i] = true;
                    horArr[2][i] = true;
                } else if (field[i][n - 1] == '#') {
                    horArr[0][i] = true;
                    horArr[2][i] = true;
                }
            } else if (count == 0) {
                horArr[0][i] = true;
                horArr[1][i] = true;
                horArr[2][i] = true;
            }
        }
        boolean[][] verArr = new boolean[3][n];
        for (int i = 0; i < n; i++) {
            int count = 0;
            for (int j = 0; j < n; j++) {
                if (field[j][i] == '#') {
                    count++;
                }
            }
             if (count == 1) {
                if (field[0][i] == '#') {
                    verArr[1][i] = true;
                    verArr[2][i] = true;
                } else if (field[n - 1][i] == '#') {
                    verArr[0][i] = true;
                    verArr[2][i] = true;
                }
            } else if (count == 0) {
                verArr[0][i] = true;
                verArr[1][i] = true;
                verArr[2][i] = true;
            }
        }
        int left = 0;
        int right = 0;
        int hor = 0;
        int up = 0;
        int down = 0;
        int ver = 0;
        int max = 0;
        for (int i = 0; i <n; i++) {
            if (horArr[0][i]) {
                left++;
            } 
            if (horArr[1][i]) {
                right++;
            }
            if (horArr[2][i]) {
                hor++;
            }
            if (verArr[0][i]) {
                up++;
            } 
            if (verArr[1][i]) {
                down++;
            }
            if (verArr[2][i]) {
                ver++;
            }
        }
        if (verArr[2][n - 1]) {
           left++;
        }
        if (verArr[2][0]) {
           right++;
        }
        if (horArr[2][n - 1]) {
           up++;
        }
        if (horArr[2][0]) {
           down++;
        }
        max = Math.max(max, left);
        max = Math.max(max, right);
        max = Math.max(max, hor);
        max = Math.max(max, up);
        max = Math.max(max, down);
        max = Math.max(max, ver);
        System.out.println(max);
    }
 }
0