結果

問題 No.307 最近色塗る問題多くない?
ユーザー rickythetarickytheta
提出日時 2015-11-28 21:41:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,462 bytes
コンパイル時間 1,349 ms
コンパイル使用メモリ 145,668 KB
実行使用メモリ 5,600 KB
最終ジャッジ日時 2023-10-12 05:32:47
合計ジャッジ時間 19,109 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 3 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 36 ms
5,224 KB
testcase_09 AC 14 ms
4,516 KB
testcase_10 AC 71 ms
4,376 KB
testcase_11 AC 240 ms
4,376 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 23 ms
4,372 KB
testcase_14 AC 3 ms
4,372 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,372 KB
testcase_17 AC 20 ms
4,372 KB
testcase_18 WA -
testcase_19 AC 46 ms
5,040 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 45 ms
4,912 KB
testcase_22 AC 33 ms
5,424 KB
testcase_23 AC 257 ms
5,600 KB
testcase_24 AC 111 ms
4,756 KB
testcase_25 AC 74 ms
4,552 KB
testcase_26 AC 297 ms
5,428 KB
testcase_27 AC 970 ms
4,376 KB
testcase_28 AC 987 ms
5,448 KB
testcase_29 AC 16 ms
4,376 KB
testcase_30 AC 2,682 ms
5,576 KB
testcase_31 AC 2,434 ms
4,376 KB
testcase_32 AC 2,428 ms
4,376 KB
testcase_33 AC 12 ms
4,588 KB
testcase_34 AC 2,430 ms
4,376 KB
testcase_35 AC 2,433 ms
4,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int h,w;
int mp[200][200];
int nxt[200][200];
bool used[200][200];
int vx[4] = {1,0,-1,0};
int vy[4] = {0,1,0,-1};

void dfs(int y,int x,int col){
  if(x<0 || y<0 || x>=w || y>=h)return;
  if(used[y][x])return;
  used[y][x] = true;
  if(mp[y][x] == col)return;
  nxt[y][x] = col;
  REP(i,4){
    dfs(y+vy[i],x+vx[i],col);
  }
}

int main(){
  cin >> h >> w;
  // vector<vi> mp(h,vi(w));
  REP(i,h)REP(j,w){
    cin>>mp[i][j];
    nxt[i][j] = mp[i][j];
  }
  int q;
  cin >> q;
  REP(_,q){
    int y,x,col;
    cin >> y >> x >> col;
    --y;--x;
    fill(used[0],used[200],false);
    dfs(y,x,col);
    if(used[0][0] && used[h-1][0] && used[0][w-1] && used[h-1][w-1]){
      REP(t,q-1-_){
        cin >> y >> x >> col;
      }
      fill(mp[0],mp[200],col);
      break;
    }
    REP(i,h)REP(j,w)mp[i][j]=nxt[i][j];
  }
  REP(i,h){
    cout << mp[i][0];
    REPR(j,w) cout << " " << mp[i][j];
    cout << endl;
  }
  return 0;
}
0