結果

問題 No.307 最近色塗る問題多くない?
ユーザー h_nosonh_noson
提出日時 2016-06-19 21:45:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,036 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 65,524 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-04-19 20:38:21
合計ジャッジ時間 11,559 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,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 190 ms
6,940 KB
testcase_08 TLE -
testcase_09 AC 376 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 6 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 32 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 3 ms
6,948 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 10 ms
6,940 KB
testcase_18 AC 24 ms
6,944 KB
testcase_19 AC 22 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 17 ms
6,944 KB
testcase_22 AC 16 ms
6,944 KB
testcase_23 AC 110 ms
6,940 KB
testcase_24 AC 40 ms
6,944 KB
testcase_25 TLE -
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:34:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |     scanf("%d%d",&h,&w);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:35:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |     rep (i,h) rep (j,w) scanf("%d",&a[i][j]);
      |                         ~~~~~^~~~~~~~~~~~~~~
main.cpp:38:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |         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) {
    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;
        if (a[nr][nc] != x)
            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--;
        if (a[r][c] != x) dfs(r,c,x);
    }
    rep (i,h) {
        rep (j,w)
            printf("%d ",a[i][j]);
        printf("\n");
    }
    return 0;
}
0