結果
| 問題 | No.640 76本のトロンボーン |
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2019-12-31 10:39:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,824 bytes |
| 記録 | |
| コンパイル時間 | 1,751 ms |
| コンパイル使用メモリ | 78,172 KB |
| 実行使用メモリ | 54,412 KB |
| 最終ジャッジ日時 | 2024-11-17 22:41:17 |
| 合計ジャッジ時間 | 4,525 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 WA * 3 |
ソースコード
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);
}
}
htensai