結果

問題 No.307 最近色塗る問題多くない?
ユーザー greentea011greentea011
提出日時 2019-04-10 11:53:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 624 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 63,940 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 20:51:07
合計ジャッジ時間 5,500 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 RE -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 60 ms
4,376 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 25 ms
4,380 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int a[410]={0};
int w,h,q;

void f(int x,int y, int r) {
    if (x<0 || x>=w) return;
    if (y<0 || y>=h) return;
    if (a[x*h+y]==r) return;
    a[x*h+y]=r;
    f(x-1,y,r);
    f(x+1,y,r);
    f(x,y-1,r);
    f(x,y+1,r);
}

int main() {
    std::cin >> w >> h;
    for (int i=0;i<w;i++) for (int j=0;j<h;j++) std::cin >> a[h*i+j];
    std::cin >> q;
    int x,y,r;
    for (int i=0;i<q;i++) {
        std::cin >> x >> y >> r;
        f(x-1,y-1,r);
    }
    for (int i=0;i<w;i++) {
        for (int j=0;j<h;j++) {
            std::cout << a[h*i+j] << " ";
        }
        std::cout << "\n";
    }
}
0