結果
| 問題 |
No.307 最近色塗る問題多くない?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-29 02:57:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,509 bytes |
| コンパイル時間 | 543 ms |
| コンパイル使用メモリ | 61,468 KB |
| 実行使用メモリ | 12,160 KB |
| 最終ジャッジ日時 | 2024-09-19 08:22:01 |
| 合計ジャッジ時間 | 12,478 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 14 TLE * 1 -- * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:61:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%d",&H);
| ~~~~~^~~~~~~~~
main.cpp:62:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%d",&W);
| ~~~~~^~~~~~~~~
main.cpp:65:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
65 | scanf("%d",&A[i][j]);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:68:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
68 | scanf("%d",&Q);
| ~~~~~^~~~~~~~~
main.cpp:71:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
71 | scanf("%d %d %d",&R,&C,&X);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int test = 0;
/* ここからが本編 */
/* pow(x,n)はx^nを返すよ! */
static int A[200][200];
int H,W;
int target_color;
int next_color;
void print_map()
{
int i,j;
if(test) puts("---map---");
for(i=0;i<H;i++) {
printf("%d",A[i][0]);
for(j=1;j<W;j++) {
printf(" %d",A[i][j]);
}
puts("");
}
if(test) puts("---------");
}
void draw(int R, int C) {
if(test) {
printf("A[%d][%d] = %d ",R,C,A[R][C]);
printf("target_color = %d\n",target_color);
}
A[R][C] = next_color;
if(test) {
printf("R = %d C = %d\n",R,C);
}
if(R-1 > -1 && A[R-1][C] == target_color) {
draw(R-1,C);
}
if(R-2 < H && A[R+1][C] == target_color) {
draw(R+1,C);
}
if(C-1 > -1 && A[R][C-1] == target_color) {
draw(R,C-1);
}
if(C-2 < W && A[R][C+1] == target_color) {
draw(R,C+1);
}
}
int main(void)
{
int i,j,k,l;
int Q;
scanf("%d",&H);
scanf("%d",&W);
for(i=0;i<H;i++) {
for(j=0;j<W;j++) {
scanf("%d",&A[i][j]);
}
}
scanf("%d",&Q);
int R,C,X;
for(i=0;i<Q;i++) {
scanf("%d %d %d",&R,&C,&X);
R--;C--;
if(A[R][C] != X) {
target_color = A[R][C]; next_color = X;
draw(R,C);
if(test) print_map();
}
}
print_map();
return 0;
}