結果

問題 No.307 最近色塗る問題多くない?
ユーザー otsnskotsnsk
提出日時 2015-12-08 15:59:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,316 bytes
コンパイル時間 1,851 ms
コンパイル使用メモリ 70,840 KB
実行使用メモリ 9,892 KB
最終ジャッジ日時 2023-10-12 21:57:06
合計ジャッジ時間 7,233 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,696 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 358 ms
4,348 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define ALL(c) begin(c), end(c)
#define sortuniq(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()),v.end())
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;

int H, W;
int A[205][205];

void paint(int r, int c, int color) {
    int curc = A[r][c];
    A[r][c] = color;
    FOR(i, 4) {
        int nr = r + d4[i], nc = c + d4[i+1];
        if (nr < 0 || H <= nr || nc < 0 || W <= nc) continue;
        if (A[nr][nc] == curc) paint(nr, nc, color);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> H >> W;
    FOR(i, H) FOR(j, W) cin >> A[i][j];
    
    int Q;
    cin >> Q;
    FOR(q, Q) {
        int R, C, X;
        cin >> R >> C >> X;
        R--; C--;
        if (A[R][C] != X) {
            paint(R, C, X);
        }
    }

    FOR(i, H) {
        cout << A[i][0];
        FORR(j, 1, W) {
            cout << ' ' << A[i][j];
        }
        cout << endl;
    }
    
    return 0;
}
0