結果

問題 No.455 冬の大三角
ユーザー GrenacheGrenache
提出日時 2016-12-06 00:11:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 1,390 bytes
コンパイル時間 3,702 ms
コンパイル使用メモリ 79,572 KB
実行使用メモリ 54,624 KB
最終ジャッジ日時 2024-06-29 21:02:46
合計ジャッジ時間 13,622 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
54,048 KB
testcase_01 AC 117 ms
53,068 KB
testcase_02 AC 133 ms
54,136 KB
testcase_03 AC 133 ms
54,204 KB
testcase_04 AC 132 ms
54,092 KB
testcase_05 AC 132 ms
54,028 KB
testcase_06 AC 132 ms
54,212 KB
testcase_07 AC 133 ms
53,864 KB
testcase_08 AC 162 ms
54,472 KB
testcase_09 AC 131 ms
54,376 KB
testcase_10 AC 134 ms
54,104 KB
testcase_11 AC 133 ms
54,076 KB
testcase_12 AC 133 ms
53,864 KB
testcase_13 AC 133 ms
53,732 KB
testcase_14 AC 132 ms
54,224 KB
testcase_15 AC 117 ms
52,752 KB
testcase_16 AC 132 ms
53,916 KB
testcase_17 AC 130 ms
54,060 KB
testcase_18 AC 132 ms
54,372 KB
testcase_19 AC 131 ms
54,196 KB
testcase_20 AC 131 ms
54,136 KB
testcase_21 AC 131 ms
54,164 KB
testcase_22 AC 116 ms
54,624 KB
testcase_23 AC 127 ms
54,024 KB
testcase_24 AC 130 ms
54,108 KB
testcase_25 AC 117 ms
53,048 KB
testcase_26 AC 131 ms
53,940 KB
testcase_27 AC 132 ms
54,488 KB
testcase_28 AC 130 ms
54,064 KB
testcase_29 AC 164 ms
54,184 KB
testcase_30 AC 145 ms
54,068 KB
testcase_31 AC 146 ms
54,308 KB
testcase_32 AC 145 ms
54,308 KB
testcase_33 AC 171 ms
54,316 KB
testcase_34 AC 134 ms
54,088 KB
testcase_35 AC 158 ms
54,032 KB
testcase_36 AC 142 ms
54,064 KB
testcase_37 AC 143 ms
54,336 KB
testcase_38 AC 140 ms
54,076 KB
testcase_39 AC 159 ms
54,060 KB
testcase_40 AC 159 ms
54,196 KB
testcase_41 AC 142 ms
54,092 KB
testcase_42 AC 143 ms
54,192 KB
testcase_43 AC 139 ms
54,108 KB
testcase_44 AC 138 ms
53,952 KB
testcase_45 AC 163 ms
54,176 KB
testcase_46 AC 130 ms
52,820 KB
testcase_47 AC 145 ms
54,356 KB
testcase_48 AC 138 ms
54,084 KB
testcase_49 AC 131 ms
54,028 KB
testcase_50 AC 119 ms
53,140 KB
testcase_51 AC 135 ms
54,100 KB
testcase_52 AC 137 ms
54,332 KB
testcase_53 AC 136 ms
54,016 KB
testcase_54 AC 123 ms
54,220 KB
testcase_55 AC 136 ms
53,900 KB
testcase_56 AC 137 ms
54,024 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