結果

問題 No.307 最近色塗る問題多くない?
ユーザー uenokuuenoku
提出日時 2017-01-14 03:06:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,440 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 94,504 KB
実行使用メモリ 9,672 KB
最終ジャッジ日時 2023-08-23 10:28:35
合計ジャッジ時間 18,281 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
9,672 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 36 ms
6,604 KB
testcase_09 AC 12 ms
5,192 KB
testcase_10 AC 231 ms
4,380 KB
testcase_11 AC 1,598 ms
4,844 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 13 ms
5,128 KB
testcase_18 AC 34 ms
6,076 KB
testcase_19 AC 31 ms
6,212 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 38 ms
5,608 KB
testcase_22 AC 28 ms
6,824 KB
testcase_23 AC 156 ms
6,780 KB
testcase_24 AC 73 ms
5,592 KB
testcase_25 AC 104 ms
6,808 KB
testcase_26 AC 186 ms
6,952 KB
testcase_27 AC 854 ms
4,380 KB
testcase_28 AC 866 ms
6,804 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 2,282 ms
7,040 KB
testcase_31 AC 2,137 ms
4,380 KB
testcase_32 AC 2,134 ms
4,380 KB
testcase_33 WA -
testcase_34 TLE -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:99:37: 警告: ‘col’ may be used uninitialized [-Wmaybe-uninitialized]
   99 |         rep(i, h) rep(j, w) f[i][j] = col;
      |                             ~~~~~~~~^~~~~
main.cpp:64:9: 備考: ‘col’ はここで定義されています
   64 |     int col;
      |         ^~~

ソースコード

diff #

#include "math.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
int h, w;
bool inrange(int x, int y)
{
    return 0 <= x && x < h && y < w && 0 <= y;
}
int f[205][205];

bool used[300][300];
int temp[300][300];
void dfs(int x, int y, int from, int c)
{
    temp[x][y] = c;
    used[x][y] = true;
    rep(i, 4)
    {
        int nx = vx[i] + x;
        int ny = vy[i] + y;
        if (inrange(nx, ny)) {
            if (f[nx][ny] == from && !used[nx][ny]) {
                temp[x][y] = c;
                used[x][y] = true;
                dfs(nx, ny, from, c);
            }
        }
    }
};

int main()
{
    cin >> h >> w;
    int a, b, c;
    rep(i, h) rep(j, w) scanf("%d", &f[i][j]);
    int q;
    cin >> q;
    bool mono = false;
    bool update;
    int col;
    rep(m, q)
    {
        scanf("%d%d%d", &a, &b, &c);

        a--, b--;
        if (!mono) {
            int color = f[0][0];
            update = false;
            rep(i, h) rep(j, w)
            {
                used[i][j] = false;
                temp[i][j] = f[i][j];
                if (f[0][0] != f[i][j])
                    update = true;
            }
            if (!update) {
                mono = true;
            }
            dfs(a, b, f[a][b], c);
            rep(i, h) rep(j, w) f[i][j] = temp[i][j];
        } else {
            col = c;
        }
        // rep(i, h) rep(j, w)
        // {
        //     cout << f[i][j];
        //     if (j == w - 1)
        //         cout << endl;
        //     else
        //         cout << ' ';
        // }
        // cout << endl;
    }
    if (mono)
        rep(i, h) rep(j, w) f[i][j] = col;
    rep(i, h) rep(j, w)
    {
        cout << f[i][j];
        if (j == w - 1)
            cout << endl;
        else
            cout << ' ';
    }
}
0