結果

問題 No.307 最近色塗る問題多くない?
ユーザー otsnsk
提出日時 2015-12-08 15:59:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,316 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 72,312 KB
実行使用メモリ 13,088 KB
最終ジャッジ日時 2024-09-14 20:11:54
合計ジャッジ時間 7,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 TLE * 2 -- * 10
権限があれば一括ダウンロードができます

ソースコード

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