結果

問題 No.455 冬の大三角
ユーザー uafr_csuafr_cs
提出日時 2017-10-30 19:21:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 1,475 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 75,276 KB
実行使用メモリ 57,260 KB
最終ジャッジ日時 2023-09-12 15:23:56
合計ジャッジ時間 13,931 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,172 KB
testcase_01 AC 123 ms
56,112 KB
testcase_02 AC 158 ms
56,244 KB
testcase_03 AC 119 ms
56,312 KB
testcase_04 AC 120 ms
56,012 KB
testcase_05 AC 121 ms
55,756 KB
testcase_06 AC 119 ms
55,964 KB
testcase_07 AC 121 ms
56,216 KB
testcase_08 AC 265 ms
56,608 KB
testcase_09 AC 119 ms
56,204 KB
testcase_10 AC 118 ms
55,908 KB
testcase_11 AC 119 ms
56,120 KB
testcase_12 AC 119 ms
55,812 KB
testcase_13 AC 120 ms
56,208 KB
testcase_14 AC 121 ms
56,396 KB
testcase_15 AC 118 ms
55,896 KB
testcase_16 AC 119 ms
56,024 KB
testcase_17 AC 119 ms
56,040 KB
testcase_18 AC 120 ms
56,072 KB
testcase_19 AC 120 ms
55,464 KB
testcase_20 AC 122 ms
56,676 KB
testcase_21 AC 117 ms
55,840 KB
testcase_22 AC 118 ms
56,064 KB
testcase_23 AC 118 ms
56,008 KB
testcase_24 AC 118 ms
55,740 KB
testcase_25 AC 118 ms
55,880 KB
testcase_26 AC 119 ms
56,292 KB
testcase_27 AC 119 ms
56,340 KB
testcase_28 AC 118 ms
56,220 KB
testcase_29 AC 241 ms
56,952 KB
testcase_30 AC 188 ms
56,324 KB
testcase_31 AC 184 ms
56,280 KB
testcase_32 AC 183 ms
56,300 KB
testcase_33 AC 255 ms
56,228 KB
testcase_34 AC 141 ms
56,152 KB
testcase_35 AC 225 ms
56,656 KB
testcase_36 AC 184 ms
56,504 KB
testcase_37 AC 184 ms
56,128 KB
testcase_38 AC 180 ms
55,656 KB
testcase_39 AC 249 ms
56,728 KB
testcase_40 AC 205 ms
57,228 KB
testcase_41 AC 188 ms
56,248 KB
testcase_42 AC 182 ms
55,756 KB
testcase_43 AC 172 ms
56,516 KB
testcase_44 AC 172 ms
56,048 KB
testcase_45 AC 230 ms
57,260 KB
testcase_46 AC 185 ms
56,340 KB
testcase_47 AC 185 ms
56,044 KB
testcase_48 AC 177 ms
55,776 KB
testcase_49 AC 121 ms
55,732 KB
testcase_50 AC 124 ms
56,008 KB
testcase_51 AC 141 ms
55,928 KB
testcase_52 AC 145 ms
55,828 KB
testcase_53 AC 164 ms
56,064 KB
testcase_54 AC 141 ms
54,432 KB
testcase_55 AC 167 ms
56,628 KB
testcase_56 AC 143 ms
55,916 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{
			if(fst_x == snd_x){
				block[fst_y][(snd_x + 1) % W] = true;
			}else if(fst_y == snd_y){
				block[(fst_y + 1) % H][snd_x] = 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