結果

問題 No.455 冬の大三角
ユーザー uafr_csuafr_cs
提出日時 2017-10-30 19:20:13
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,475 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 75,416 KB
実行使用メモリ 58,324 KB
最終ジャッジ日時 2023-08-14 13:18:29
合計ジャッジ時間 14,556 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
39,300 KB
testcase_01 WA -
testcase_02 AC 142 ms
39,740 KB
testcase_03 AC 116 ms
39,188 KB
testcase_04 AC 117 ms
39,316 KB
testcase_05 AC 117 ms
39,056 KB
testcase_06 AC 115 ms
39,176 KB
testcase_07 AC 116 ms
39,240 KB
testcase_08 AC 260 ms
42,016 KB
testcase_09 AC 119 ms
39,452 KB
testcase_10 RE -
testcase_11 AC 117 ms
39,668 KB
testcase_12 WA -
testcase_13 AC 118 ms
39,556 KB
testcase_14 AC 117 ms
39,248 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 AC 116 ms
39,376 KB
testcase_19 AC 116 ms
39,492 KB
testcase_20 AC 117 ms
39,524 KB
testcase_21 AC 117 ms
39,656 KB
testcase_22 WA -
testcase_23 AC 117 ms
39,080 KB
testcase_24 AC 117 ms
39,792 KB
testcase_25 WA -
testcase_26 AC 118 ms
39,248 KB
testcase_27 AC 122 ms
39,608 KB
testcase_28 AC 116 ms
39,368 KB
testcase_29 AC 227 ms
40,664 KB
testcase_30 AC 186 ms
39,744 KB
testcase_31 AC 184 ms
40,184 KB
testcase_32 AC 184 ms
39,720 KB
testcase_33 AC 253 ms
40,432 KB
testcase_34 AC 137 ms
39,828 KB
testcase_35 AC 212 ms
40,560 KB
testcase_36 AC 183 ms
39,952 KB
testcase_37 AC 181 ms
39,952 KB
testcase_38 AC 184 ms
39,980 KB
testcase_39 AC 246 ms
40,868 KB
testcase_40 AC 210 ms
40,080 KB
testcase_41 AC 185 ms
39,832 KB
testcase_42 AC 181 ms
39,588 KB
testcase_43 AC 159 ms
39,708 KB
testcase_44 AC 168 ms
39,808 KB
testcase_45 AC 230 ms
40,156 KB
testcase_46 AC 185 ms
40,168 KB
testcase_47 AC 185 ms
40,100 KB
testcase_48 AC 185 ms
40,292 KB
testcase_49 AC 117 ms
39,640 KB
testcase_50 RE -
testcase_51 AC 134 ms
39,268 KB
testcase_52 AC 149 ms
39,704 KB
testcase_53 AC 161 ms
40,056 KB
testcase_54 AC 133 ms
39,528 KB
testcase_55 AC 165 ms
40,008 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