結果

問題 No.307 最近色塗る問題多くない?
ユーザー h_nosonh_noson
提出日時 2016-06-19 21:42:53
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,024 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 64,524 KB
実行使用メモリ 13,088 KB
最終ジャッジ日時 2024-04-19 20:37:29
合計ジャッジ時間 6,935 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 277 ms
6,944 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |     scanf("%d%d",&h,&w);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:36:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |     rep (i,h) rep (j,w) scanf("%d",&a[i][j]);
      |                         ~~~~~^~~~~~~~~~~~~~~
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
main.cpp:42:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |         scanf("%d%d%d",&r,&c,&x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)

typedef long long ll;

int a[200][200];
int h, w;

void dfs(int r, int c, int x) {
    if (a[r][c] == x)
        return;
    a[r][c] = x;
    int i;
    int dxy[] = {1,0,-1,0};
    rep (i,4) {
        int nr = r + dxy[i];
        int nc = c + dxy[(i+1)%4];
        if (nr < 0 || nr >= h || nc < 0 || nc >= w) continue;
        dfs(nr,nc,x);
    }
}

int main(void) {
    int i, j;
    scanf("%d%d",&h,&w);
    rep (i,h) rep (j,w) scanf("%d",&a[i][j]);

    int q;
    scanf("%d",&q);
    while (q--) {
        int r, c, x;
        scanf("%d%d%d",&r,&c,&x);
        r--; c--;
        dfs(r,c,x);
    }
    rep (i,h) {
        rep (j,w)
            printf("%d ",a[i][j]);
        printf("\n");
    }
    return 0;
}
0