結果

問題 No.307 最近色塗る問題多くない?
ユーザー d2verbd2verb
提出日時 2015-11-28 00:32:16
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,798 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 94,680 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 00:50:35
合計ジャッジ時間 6,870 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 328 ms
4,352 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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int H, W;
vvint A;

void dfs(int r, int c, int x){
  int color = A[r][c];
  A[r][c] = x;
  for(int i = 0; i < 4; i++){
    int nr = r + dy[i];
    int nc = c + dx[i];
    if(0 <= nr && nr < H && 0 <= nc && nc < W && A[nr][nc] == color && A[nr][nc] != x){
      dfs(nr, nc, x);
    }
  }
}

int main(void){
  ios_base::sync_with_stdio(0);
  cin >> H >> W;
  A = vvint(H);
  int input;
  
  rep(i, H){
    rep(j, W){
      cin >> input;
      A[i].push_back(input);
    }
  }
  
  int Q, R, C, X;
  cin >> Q;
  rep(i, Q){
    cin >> R >> C >> X;
    R--;  C--;
    dfs(R, C, X);
  }

  rep(i, H){
    rep(j, W){
      if(j) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }
  return 0; 
}
0