結果

問題 No.455 冬の大三角
ユーザー htensaihtensai
提出日時 2019-12-19 14:49:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,598 bytes
コンパイル時間 3,456 ms
コンパイル使用メモリ 73,332 KB
実行使用メモリ 49,960 KB
最終ジャッジ日時 2023-09-21 07:02:58
合計ジャッジ時間 10,236 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,548 KB
testcase_01 AC 45 ms
49,864 KB
testcase_02 AC 44 ms
49,480 KB
testcase_03 AC 44 ms
49,552 KB
testcase_04 AC 44 ms
49,204 KB
testcase_05 AC 45 ms
49,128 KB
testcase_06 AC 45 ms
49,368 KB
testcase_07 AC 45 ms
49,184 KB
testcase_08 AC 48 ms
49,216 KB
testcase_09 AC 44 ms
49,448 KB
testcase_10 AC 45 ms
49,296 KB
testcase_11 AC 44 ms
49,328 KB
testcase_12 AC 45 ms
49,416 KB
testcase_13 AC 43 ms
49,632 KB
testcase_14 AC 44 ms
49,352 KB
testcase_15 AC 44 ms
49,524 KB
testcase_16 AC 44 ms
49,276 KB
testcase_17 AC 45 ms
49,668 KB
testcase_18 AC 44 ms
49,304 KB
testcase_19 AC 45 ms
49,264 KB
testcase_20 AC 44 ms
49,400 KB
testcase_21 AC 44 ms
49,580 KB
testcase_22 AC 44 ms
49,388 KB
testcase_23 AC 44 ms
49,276 KB
testcase_24 AC 45 ms
49,220 KB
testcase_25 AC 44 ms
49,280 KB
testcase_26 AC 46 ms
49,272 KB
testcase_27 AC 45 ms
49,276 KB
testcase_28 AC 45 ms
49,284 KB
testcase_29 AC 47 ms
49,380 KB
testcase_30 AC 47 ms
49,124 KB
testcase_31 AC 46 ms
49,220 KB
testcase_32 AC 45 ms
49,216 KB
testcase_33 AC 47 ms
49,476 KB
testcase_34 AC 45 ms
49,480 KB
testcase_35 AC 47 ms
49,328 KB
testcase_36 AC 46 ms
49,352 KB
testcase_37 AC 46 ms
49,500 KB
testcase_38 AC 45 ms
49,460 KB
testcase_39 AC 48 ms
49,572 KB
testcase_40 AC 46 ms
49,324 KB
testcase_41 AC 46 ms
49,324 KB
testcase_42 AC 46 ms
49,960 KB
testcase_43 AC 46 ms
49,296 KB
testcase_44 AC 46 ms
49,308 KB
testcase_45 AC 46 ms
49,224 KB
testcase_46 AC 47 ms
47,208 KB
testcase_47 AC 46 ms
49,448 KB
testcase_48 AC 45 ms
49,536 KB
testcase_49 AC 44 ms
49,300 KB
testcase_50 AC 44 ms
49,312 KB
testcase_51 AC 45 ms
49,408 KB
testcase_52 AC 45 ms
49,776 KB
testcase_53 AC 45 ms
49,336 KB
testcase_54 AC 44 ms
49,464 KB
testcase_55 AC 45 ms
49,400 KB
testcase_56 AC 46 ms
49,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    static HashSet<Integer>[] graph;
    static int n;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 2);
        int h = Integer.parseInt(first[0]);
        int w = Integer.parseInt(first[1]);
        int h1 = -1;
        int w1 = -1;
        int h2 = -1;
        int w2 = -1;
        char[][] field = new char[h][];
        for (int i = 0; i < h; i++) {
            field[i] = br.readLine().toCharArray();
            for (int j = 0; j < w; j++) {
                if (field[i][j] == '*') {
                    if (h1 == -1) {
                        h1 = i;
                        w1 = j;
                    } else {
                        h2 = i;
                        w2 = j;
                    }
                }
            }
        }
        int h3;
        int w3;
        if (h1 == h2) {
            if (h1 == 0) {
                h3 = h1 + 1;
                w3 = w1;
            } else {
                h3 = h1 - 1;
                w3 = w1;
            }
        } else {
            if (w1 == 0) {
                h3 = h1;
                w3 = w1 + 1;
            } else {
                h3 = h1;
                w3 = w1 - 1;
            }
        }
        field[h3][w3] = '*';
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < h; i++) {
            sb.append(new String(field[i])).append("\n");
        }
        System.out.print(sb);
    }
}
0