結果

問題 No.455 冬の大三角
ユーザー crazybbb3crazybbb3
提出日時 2017-01-16 21:16:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 2,455 bytes
コンパイル時間 2,961 ms
コンパイル使用メモリ 75,448 KB
実行使用メモリ 51,224 KB
最終ジャッジ日時 2023-09-12 09:48:53
合計ジャッジ時間 8,871 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,476 KB
testcase_01 AC 45 ms
49,432 KB
testcase_02 AC 46 ms
49,788 KB
testcase_03 AC 44 ms
49,444 KB
testcase_04 AC 44 ms
49,592 KB
testcase_05 AC 44 ms
49,656 KB
testcase_06 AC 43 ms
49,612 KB
testcase_07 AC 44 ms
47,572 KB
testcase_08 AC 69 ms
51,148 KB
testcase_09 AC 45 ms
49,544 KB
testcase_10 AC 44 ms
49,460 KB
testcase_11 AC 43 ms
49,428 KB
testcase_12 AC 43 ms
49,964 KB
testcase_13 AC 43 ms
49,452 KB
testcase_14 AC 43 ms
47,500 KB
testcase_15 AC 43 ms
49,620 KB
testcase_16 AC 43 ms
49,544 KB
testcase_17 AC 45 ms
49,472 KB
testcase_18 AC 43 ms
49,612 KB
testcase_19 AC 44 ms
49,432 KB
testcase_20 AC 43 ms
49,548 KB
testcase_21 AC 44 ms
49,504 KB
testcase_22 AC 44 ms
49,412 KB
testcase_23 AC 44 ms
49,608 KB
testcase_24 AC 46 ms
49,548 KB
testcase_25 AC 44 ms
49,632 KB
testcase_26 AC 44 ms
49,412 KB
testcase_27 AC 43 ms
49,540 KB
testcase_28 AC 44 ms
49,488 KB
testcase_29 AC 62 ms
50,332 KB
testcase_30 AC 56 ms
50,312 KB
testcase_31 AC 55 ms
50,252 KB
testcase_32 AC 54 ms
50,296 KB
testcase_33 AC 67 ms
51,224 KB
testcase_34 AC 46 ms
49,872 KB
testcase_35 AC 57 ms
50,492 KB
testcase_36 AC 55 ms
48,464 KB
testcase_37 AC 52 ms
50,204 KB
testcase_38 AC 52 ms
50,488 KB
testcase_39 AC 63 ms
50,552 KB
testcase_40 AC 57 ms
50,444 KB
testcase_41 AC 55 ms
49,684 KB
testcase_42 AC 54 ms
50,240 KB
testcase_43 AC 51 ms
49,568 KB
testcase_44 AC 50 ms
49,480 KB
testcase_45 AC 59 ms
50,400 KB
testcase_46 AC 56 ms
50,248 KB
testcase_47 AC 55 ms
50,524 KB
testcase_48 AC 53 ms
50,368 KB
testcase_49 AC 44 ms
49,444 KB
testcase_50 AC 43 ms
49,768 KB
testcase_51 AC 45 ms
49,560 KB
testcase_52 AC 46 ms
49,544 KB
testcase_53 AC 47 ms
49,624 KB
testcase_54 AC 46 ms
49,652 KB
testcase_55 AC 49 ms
49,560 KB
testcase_56 AC 46 ms
49,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int h = ni(), w = ni();
        char[][] s = new char[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = ns().toCharArray();
        }
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '*') {
                    list.add(i);
                    list.add(j);
                }
            }
        }

        if (list.get(0) == 0 && list.get(2) == 0 || list.get(1) == 0 && list.get(3) == 0) {
            s[h - 1][w - 1] = '*';
        } else if (list.get(0) * list.get(3) == list.get(1) * list.get(2)) {
            s[0][w - 1] = '*';
        } else {
            s[0][0] = '*';
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                out.print(s[i][j]);
            }
            out.println();
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0