結果

問題 No.307 最近色塗る問題多くない?
ユーザー simansiman
提出日時 2023-06-08 01:57:05
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,202 bytes
コンパイル時間 6,050 ms
コンパイル使用メモリ 105,652 KB
実行使用メモリ 10,780 KB
最終ジャッジ日時 2023-08-28 20:20:18
合計ジャッジ時間 19,780 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 190 ms
4,380 KB
testcase_08 TLE -
testcase_09 AC 381 ms
5,356 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 41 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 12 ms
5,132 KB
testcase_18 AC 27 ms
5,996 KB
testcase_19 AC 26 ms
6,192 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 22 ms
5,536 KB
testcase_22 AC 22 ms
6,792 KB
testcase_23 AC 113 ms
6,712 KB
testcase_24 AC 44 ms
5,480 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int g_visited[210][210];
int g_vid;
int A[210][210];

const int DY[4] = {-1, 0, 1, 0};
const int DX[4] = {0, 1, 0, -1};

int fill_x(int y, int x, int c, int nc) {
  int cnt = 1;
  g_visited[y][x] = g_vid;
  A[y][x] = nc;

  for (int dir = 0; dir < 4; ++dir) {
    int ny = y + DY[dir];
    int nx = x + DX[dir];
    if (A[ny][nx] != c) continue;

    cnt += fill_x(ny, nx, c, nc);
  }

  return cnt;
}

int main() {
  g_vid = 0;
  memset(g_visited, -1, sizeof(g_visited));

  int H, W;
  cin >> H >> W;
  memset(A, -1, sizeof(A));

  for (int y = 1; y <= H; ++y) {
    for (int x = 1; x <= W; ++x) {
      cin >> A[y][x];
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int R, C, X;
    cin >> R >> C >> X;

    if (A[R][C] == X) continue;
    fill_x(R, C, A[R][C], X);
  }

  for (int y = 1; y <= H; ++y) {
    for (int x = 1; x <= W; ++x) {
      cout << A[y][x];
      if (x < W) cout << " ";
    }
    cout << endl;
  }

  return 0;
}
0