結果
問題 | No.455 冬の大三角 |
ユーザー |
![]() |
提出日時 | 2017-10-30 19:21:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 259 ms / 2,000 ms |
コード長 | 1,475 bytes |
コンパイル時間 | 1,802 ms |
コンパイル使用メモリ | 78,280 KB |
実行使用メモリ | 42,960 KB |
最終ジャッジ日時 | 2024-06-30 03:21:10 |
合計ジャッジ時間 | 11,869 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
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();}}}