結果
| 問題 |
No.307 最近色塗る問題多くない?
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-06-08 01:57:05 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,202 bytes |
| コンパイル時間 | 1,798 ms |
| コンパイル使用メモリ | 139,580 KB |
| 実行使用メモリ | 14,976 KB |
| 最終ジャッジ日時 | 2024-12-30 07:42:33 |
| 合計ジャッジ時間 | 25,601 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 TLE * 4 |
ソースコード
#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;
}
siman