結果

問題 No.307 最近色塗る問題多くない?
ユーザー tubo28tubo28
提出日時 2015-11-27 23:58:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,768 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 147,148 KB
実行使用メモリ 8,388 KB
最終ジャッジ日時 2023-10-12 01:52:01
合計ジャッジ時間 10,257 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); }
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

int h,w;
int g[222][222];
int q;
int r[100000], c[100000], x[100000];
int vis[222][222];

void solve(){
    static pair<int,int> stack[222*222 + 100];
    rep(qi,q){
        memset(vis,0,sizeof(vis));
        int si = r[qi], sj = c[qi];
        int orig = x[qi];
        int sz = 0;
        stack[sz++] = mp(si,sj);
        while(sz){
            int ci,cj;
            tie(ci,cj) = stack[sz-1];
            --sz;
            vis[ci][cj] = true;
            g[ci][cj] = orig;
            int di[] = {0,1,0,-1};
            int dj[] = {1,0,-1,0};
            rep(dd,4){
                int ni = ci + di[dd];
                int nj = cj + dj[dd];
                if(ni < 0 || nj < 0) continue;
                if(ni >= h || nj >= w) continue;
                if(vis[ni][nj]) continue;
                if(g[ci][cj] != g[ni][nj]) continue;
                stack[sz++] = mp(ni,nj);
            }
        }
    }
}

int main(){
    fastios();
    while(cin >> h >> w){
        rep(i,h)rep(j,w) cin >> g[i][j];
        cin >> q;
        rep(i,q) cin >> r[i] >> c[i] >> x[i], r[i]--, c[i]--;
        solve();
        rep(i,h){
            rep(j,w){
                cout << g[i][j] << (j != w-1 ? ' ' : '\n');
            }
        }
    }
}
0