結果

問題 No.640 76本のトロンボーン
ユーザー 37zigen37zigen
提出日時 2018-05-30 22:58:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,690 bytes
コンパイル時間 2,695 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 58,940 KB
最終ジャッジ日時 2023-09-12 20:50:31
合計ジャッジ時間 6,124 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,760 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 118 ms
56,432 KB
testcase_05 AC 119 ms
56,216 KB
testcase_06 AC 180 ms
58,608 KB
testcase_07 AC 183 ms
58,940 KB
testcase_08 AC 182 ms
58,792 KB
testcase_09 AC 181 ms
58,700 KB
testcase_10 AC 184 ms
58,400 KB
testcase_11 AC 181 ms
58,644 KB
testcase_12 AC 181 ms
58,276 KB
testcase_13 AC 121 ms
55,928 KB
testcase_14 AC 176 ms
58,444 KB
testcase_15 AC 119 ms
55,852 KB
testcase_16 AC 122 ms
56,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[][] s = new char[N][N];
		for (int i = 0; i < N; ++i) {
			s[i] = sc.next().toCharArray();
		}
		int ans = 0;
		{
			boolean f = true;
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					if (i == 0 || i == N - 1 || j == 0 || j == N - 1) {
						f &= s[i][j] == '.';
					}
				}
			}
			if (f)
				ans = 4;
		}
		for (int t = 0; t < 2; ++t) {
			ans = Math.max(solve(s), ans);
			for (int i = 0; i < N; ++i) {
				for (int j = i + 1; j < N; ++j) {
					char tmp = s[i][j];
					s[i][j] = s[j][i];
					s[j][i] = tmp;
				}
			}
		}
		System.out.println(ans);
	}

	int solve(char[][] s) {
		int N = s.length;
		int ret = 0;
		for (int i = 0; i < s.length; ++i) {
			for (int d = 0; d < 1; ++d) {
				char[][] s2 = new char[N][N];
				for (int j = 0; j < N; ++j)
					for (int k = 0; k < N; ++k)
						s2[j][k] = s[j][k];
				boolean flag = true;
				for (int j = d; j < N - 1 + d; ++j) {
					flag &= s2[i][j] == '.';
					s2[i][j] = '#';
				}
				ret = Math.max(ret, (flag ? 1 : 0) + go(s2));
			}
		}
		return ret;
	}

	int go(char[][] s) {
		int ret = 0;
		int N = s.length;
		for (int i = 0; i < N; ++i) {
			boolean flag = true;
			for (int j = 1; j < N - 1; ++j) {
				flag &= s[j][i] == '.';
			}
			if (flag && (s[0][i] == '.' || s[N - 1][i] == '.')) {
				++ret;
			}
		}
		return ret;
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0