結果

問題 No.455 冬の大三角
ユーザー GrenacheGrenache
提出日時 2016-12-06 00:11:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,390 bytes
コンパイル時間 3,742 ms
コンパイル使用メモリ 76,312 KB
実行使用メモリ 56,404 KB
最終ジャッジ日時 2023-09-12 08:14:02
合計ジャッジ時間 14,555 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,584 KB
testcase_01 AC 129 ms
55,692 KB
testcase_02 AC 133 ms
55,816 KB
testcase_03 AC 129 ms
55,616 KB
testcase_04 AC 131 ms
55,720 KB
testcase_05 AC 132 ms
55,704 KB
testcase_06 AC 129 ms
55,720 KB
testcase_07 AC 130 ms
55,424 KB
testcase_08 AC 164 ms
56,404 KB
testcase_09 AC 130 ms
55,436 KB
testcase_10 AC 128 ms
55,676 KB
testcase_11 AC 129 ms
55,788 KB
testcase_12 AC 129 ms
55,356 KB
testcase_13 AC 129 ms
55,452 KB
testcase_14 AC 131 ms
55,456 KB
testcase_15 AC 130 ms
55,624 KB
testcase_16 AC 129 ms
55,664 KB
testcase_17 AC 128 ms
55,632 KB
testcase_18 AC 128 ms
55,688 KB
testcase_19 AC 129 ms
55,760 KB
testcase_20 AC 129 ms
55,480 KB
testcase_21 AC 129 ms
55,704 KB
testcase_22 AC 128 ms
55,484 KB
testcase_23 AC 128 ms
55,720 KB
testcase_24 AC 129 ms
55,488 KB
testcase_25 AC 128 ms
55,600 KB
testcase_26 AC 128 ms
55,604 KB
testcase_27 AC 129 ms
55,720 KB
testcase_28 AC 127 ms
55,400 KB
testcase_29 AC 156 ms
56,060 KB
testcase_30 AC 140 ms
55,704 KB
testcase_31 AC 142 ms
55,380 KB
testcase_32 AC 140 ms
55,696 KB
testcase_33 AC 160 ms
55,936 KB
testcase_34 AC 135 ms
53,980 KB
testcase_35 AC 160 ms
56,112 KB
testcase_36 AC 142 ms
55,768 KB
testcase_37 AC 140 ms
55,756 KB
testcase_38 AC 140 ms
55,692 KB
testcase_39 AC 159 ms
56,284 KB
testcase_40 AC 155 ms
55,912 KB
testcase_41 AC 143 ms
55,700 KB
testcase_42 AC 140 ms
55,616 KB
testcase_43 AC 140 ms
55,476 KB
testcase_44 AC 134 ms
55,728 KB
testcase_45 AC 155 ms
56,068 KB
testcase_46 AC 140 ms
55,744 KB
testcase_47 AC 141 ms
55,980 KB
testcase_48 AC 138 ms
55,824 KB
testcase_49 AC 131 ms
55,684 KB
testcase_50 AC 130 ms
55,444 KB
testcase_51 AC 133 ms
55,696 KB
testcase_52 AC 135 ms
55,976 KB
testcase_53 AC 134 ms
55,704 KB
testcase_54 AC 136 ms
55,796 KB
testcase_55 AC 135 ms
55,508 KB
testcase_56 AC 140 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder455 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] s = new char[h][];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}

		Set<Integer> hsx = new HashSet<>();
		Set<Integer> hsy = new HashSet<>();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '*') {
					hsx.add(j);
					hsy.add(i);
				}
			}
		}

		List<Integer> alx = new ArrayList<>(hsx);
		List<Integer> aly = new ArrayList<>(hsy);

		if (alx.size() == 2 && aly.size() == 2) {
			s[aly.get(0)][alx.get(0)] = '*';
			s[aly.get(0)][alx.get(1)] = '*';
		} else if (alx.size() == 2 && aly.size() == 1) {
			int y = aly.get(0) + 1;
			if (y >= h) {
				y -= 2;
			}
			s[y][alx.get(0)] = '*';
		} else if (alx.size() == 1 && aly.size() == 2) {
			int x = alx.get(0) + 1;
			if (x >= w) {
				x -= 2;
			}
			s[aly.get(0)][x] = '*';
		}

		for (int i = 0; i < h; i++) {
			pr.println(s[i]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0