結果
問題 | No.307 最近色塗る問題多くない? |
ユーザー | atkrym |
提出日時 | 2016-10-18 17:48:35 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,573 bytes |
コンパイル時間 | 2,259 ms |
コンパイル使用メモリ | 77,676 KB |
実行使用メモリ | 78,288 KB |
最終ジャッジ日時 | 2024-05-02 02:37:30 |
合計ジャッジ時間 | 11,092 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 117 ms
46,328 KB |
testcase_01 | AC | 114 ms
40,384 KB |
testcase_02 | AC | 109 ms
40,240 KB |
testcase_03 | AC | 120 ms
41,212 KB |
testcase_04 | AC | 179 ms
42,676 KB |
testcase_05 | AC | 123 ms
41,284 KB |
testcase_06 | AC | 126 ms
41,236 KB |
testcase_07 | AC | 1,050 ms
59,364 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); private static int[][] ary; private static int h; private static int w; public static void main(String[] args) throws Exception { h = sc.nextInt(); w = sc.nextInt(); ary = new int[h][w]; for (int i = 0;i < h;i++) { for (int j = 0;j < w;j++) { ary[i][j] = sc.nextInt(); } } int q = sc.nextInt(); for (int i = 0;i < q;i++) { int x = sc.nextInt() - 1; int y = sc.nextInt() - 1; int c = sc.nextInt(); int pc = ary[x][y]; draw(x, y, c, pc); } show(); } private static void draw(int x, int y, int c, int pc) { ary[x][y] = c; int[] dx = {-1, 0, 1, 0}; int[] dy = {0, 1, 0, -1}; for (int i = 0;i < 4;i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (0 <= nx && nx < h && 0 <= ny && ny < w) { int nc = ary[nx][ny]; if (pc == nc && c != nc) { draw(nx, ny, c, pc); } } } } private static void show() { for (int i = 0;i < h;i++) { StringBuilder sb = new StringBuilder(); for (int j = 0;j < w;j++) { sb.append(ary[i][j]).append(" "); } System.out.println(sb.substring(0, sb.length()-1)); } } }