結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
41,220 KB
testcase_01 WA -
testcase_02 AC 169 ms
41,592 KB
testcase_03 AC 140 ms
41,344 KB
testcase_04 AC 143 ms
41,112 KB
testcase_05 AC 145 ms
41,208 KB
testcase_06 AC 145 ms
41,116 KB
testcase_07 AC 142 ms
41,392 KB
testcase_08 AC 283 ms
42,648 KB
testcase_09 AC 148 ms
41,544 KB
testcase_10 RE -
testcase_11 AC 139 ms
41,264 KB
testcase_12 WA -
testcase_13 AC 141 ms
41,424 KB
testcase_14 AC 143 ms
41,228 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 AC 137 ms
41,224 KB
testcase_19 AC 137 ms
41,160 KB
testcase_20 AC 137 ms
41,132 KB
testcase_21 AC 139 ms
41,220 KB
testcase_22 WA -
testcase_23 AC 126 ms
39,896 KB
testcase_24 AC 141 ms
41,080 KB
testcase_25 WA -
testcase_26 AC 139 ms
41,328 KB
testcase_27 AC 138 ms
41,248 KB
testcase_28 AC 139 ms
41,040 KB
testcase_29 AC 272 ms
42,036 KB
testcase_30 AC 229 ms
41,720 KB
testcase_31 AC 216 ms
41,596 KB
testcase_32 AC 217 ms
41,760 KB
testcase_33 AC 286 ms
42,536 KB
testcase_34 AC 161 ms
41,560 KB
testcase_35 AC 238 ms
42,248 KB
testcase_36 AC 208 ms
41,776 KB
testcase_37 AC 204 ms
41,644 KB
testcase_38 AC 185 ms
40,612 KB
testcase_39 AC 261 ms
42,108 KB
testcase_40 AC 232 ms
42,044 KB
testcase_41 AC 219 ms
41,720 KB
testcase_42 AC 205 ms
41,604 KB
testcase_43 AC 190 ms
41,404 KB
testcase_44 AC 200 ms
41,676 KB
testcase_45 AC 268 ms
42,228 KB
testcase_46 AC 217 ms
41,852 KB
testcase_47 AC 214 ms
41,780 KB
testcase_48 AC 207 ms
41,576 KB
testcase_49 AC 145 ms
41,072 KB
testcase_50 RE -
testcase_51 AC 162 ms
41,328 KB
testcase_52 AC 170 ms
41,504 KB
testcase_53 AC 182 ms
41,664 KB
testcase_54 AC 156 ms
41,396 KB
testcase_55 AC 180 ms
41,404 KB
testcase_56 RE -
権限があれば一括ダウンロードができます

ソースコード

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{
			if(fst_x == snd_x){
				block[fst_x][(snd_y + 1) % H] = true;
			}else if(fst_y == snd_y){
				block[(fst_x + 1) % W][snd_y] = true;
			}else if(fst_x < snd_x && fst_y < snd_y){
				block[snd_y][fst_x] = true;
			}else if(snd_x < fst_x && snd_y < fst_y){
				block[snd_y][fst_x] = true;
			}else{
				block[snd_y][fst_x] = true;
			}
		}
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				System.out.print(block[i][j] ? "*" : "-");
			}
			System.out.println();
		}
	}
}
0