結果

問題 No.455 冬の大三角
ユーザー uafr_csuafr_cs
提出日時 2017-10-30 19:08:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 2,556 ms
コンパイル使用メモリ 78,032 KB
実行使用メモリ 42,364 KB
最終ジャッジ日時 2024-05-02 01:29:35
合計ジャッジ時間 14,839 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
41,228 KB
testcase_01 AC 137 ms
41,216 KB
testcase_02 AC 180 ms
41,564 KB
testcase_03 AC 136 ms
40,980 KB
testcase_04 AC 137 ms
41,036 KB
testcase_05 WA -
testcase_06 AC 137 ms
41,256 KB
testcase_07 AC 141 ms
41,324 KB
testcase_08 AC 274 ms
42,284 KB
testcase_09 AC 136 ms
41,232 KB
testcase_10 WA -
testcase_11 AC 135 ms
41,128 KB
testcase_12 WA -
testcase_13 AC 134 ms
40,928 KB
testcase_14 WA -
testcase_15 AC 136 ms
41,448 KB
testcase_16 WA -
testcase_17 AC 136 ms
41,044 KB
testcase_18 WA -
testcase_19 AC 136 ms
40,988 KB
testcase_20 AC 120 ms
40,044 KB
testcase_21 WA -
testcase_22 AC 121 ms
40,192 KB
testcase_23 AC 134 ms
41,304 KB
testcase_24 AC 136 ms
41,076 KB
testcase_25 AC 133 ms
41,196 KB
testcase_26 AC 136 ms
41,212 KB
testcase_27 WA -
testcase_28 AC 137 ms
41,136 KB
testcase_29 AC 250 ms
42,052 KB
testcase_30 AC 209 ms
41,712 KB
testcase_31 AC 219 ms
41,632 KB
testcase_32 AC 212 ms
41,732 KB
testcase_33 AC 281 ms
42,352 KB
testcase_34 AC 161 ms
41,348 KB
testcase_35 AC 234 ms
41,884 KB
testcase_36 AC 207 ms
41,856 KB
testcase_37 AC 194 ms
41,524 KB
testcase_38 AC 195 ms
41,652 KB
testcase_39 AC 252 ms
42,364 KB
testcase_40 AC 228 ms
41,824 KB
testcase_41 AC 209 ms
41,812 KB
testcase_42 AC 192 ms
40,724 KB
testcase_43 AC 181 ms
41,696 KB
testcase_44 AC 191 ms
41,396 KB
testcase_45 AC 248 ms
42,068 KB
testcase_46 AC 206 ms
41,608 KB
testcase_47 AC 206 ms
41,576 KB
testcase_48 AC 205 ms
41,696 KB
testcase_49 AC 137 ms
41,268 KB
testcase_50 AC 142 ms
41,084 KB
testcase_51 AC 139 ms
40,032 KB
testcase_52 WA -
testcase_53 AC 181 ms
41,584 KB
testcase_54 AC 153 ms
41,544 KB
testcase_55 AC 190 ms
41,544 KB
testcase_56 AC 156 ms
41,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int H = sc.nextInt();
		final int W = sc.nextInt();
		
		boolean[][] block = new boolean[H][W];
		for(int i = 0; i < H; i++){
			final char[] ins = sc.next().toCharArray();
			
			for(int j = 0; j < W; j++){
				block[i][j] = ins[j] == '*';
			}
		}
		
		int fst_x = -1, fst_y = -1, snd_x = -1, snd_y = -1;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(!block[i][j]){ continue; }
				
				if(fst_x < 0){
					fst_x = j;
					fst_y = i;
				}else{
					snd_x = j;
					snd_y = i;
				}
			}
		}
		
		if(H * W <= 4){
			LOOP:
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(block[i][j]){ continue; }
					
					block[i][j] = true; break LOOP;
				}
			}
		}else{
			LOOP:
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(block[i][j]){ continue; }
					if(i == fst_y || i == snd_y){ continue; }
					if(j == fst_x || j == snd_x){ continue; }
					
					block[i][j] = true; break LOOP;
				}
			}
		}
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				System.out.print(block[i][j] ? "*" : "-");
			}
			System.out.println();
		}
	}
}
0