結果

問題 No.455 冬の大三角
ユーザー Mcpu3
提出日時 2018-09-27 21:00:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 902 bytes
コンパイル時間 2,326 ms
コンパイル使用メモリ 77,272 KB
実行使用メモリ 41,628 KB
最終ジャッジ日時 2024-10-12 04:35:11
合計ジャッジ時間 11,938 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt(), h[] = new int[2], w[] = new int[2], k = 0;
        char S[][] = new char[H][W + 1];
        for (int i = 0; i < H; ++i) {
            S[i] = sc.next().toCharArray();
            for (int j = 0; j < W && k != 2; ++j) {
                if (S[i][j] == '*') {
                    h[k] = i;
                    w[k] = j;
                    ++k;
                }
            }
        }
        sc.close();
        if (h[0] == h[1]) {
            if (h[0] == 0) S[1][0] = '*';
            else S[0][0] = '*';
        }
        else {
            if (w[0] == 0) S[h[0]][1] = '*';
            else S[h[0]][w[0] - 1] = '*';
        }
        for (int i = 0; i < H; ++i) System.out.println(S[i]);
    }
}
0