結果
| 問題 |
No.307 最近色塗る問題多くない?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-07 11:23:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,982 bytes |
| コンパイル時間 | 1,504 ms |
| コンパイル使用メモリ | 164,620 KB |
| 実行使用メモリ | 814,160 KB |
| 最終ジャッジ日時 | 2024-09-24 15:09:47 |
| 合計ジャッジ時間 | 5,897 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 MLE * 1 -- * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:86:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
86 | scanf("%d",&H);
| ~~~~~^~~~~~~~~
main.cpp:87:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
87 | scanf("%d",&W);
| ~~~~~^~~~~~~~~
main.cpp:90:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
90 | scanf("%d",&A[i][j]);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:93:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
93 | scanf("%d",&Q);
| ~~~~~^~~~~~~~~
main.cpp:96:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
96 | scanf("%d %d %d",&R,&C,&X);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#ifdef _MSC_VER
#include "bits\stdc++.h"
#else
#include <bits/stdc++.h>
#endif
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <list>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
// #define rep(i,n) REP(i,1,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X) ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
// #define int ll
using namespace std;
bool 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("---------");
}
struct Point{
int R,C;
};
void draw(int R, int C) {
int i,j;
queue<Point> q;
Point start = {R,C};
int dR[] = { 0, 0,-1, 1};
int dC[] = { 1,-1, 0, 0};
q.push(start);
while( q.size() ) {
Point now = q.front(); q.pop();
if(test) {
printf("A[%d][%d] = %d ",now.R,now.C,A[R][C]);
printf("target_color = %d\n",target_color);
printf("R = %d C = %d\n",now.R,now.C);
}
A[now.R][now.C] = next_color;
rep(i,4) {
Point next;
next.R = now.R+dR[i];
next.C = now.C+dC[i];
if(next.R < 0 || H <= next.R) continue;
else if(next.C < 0 || W <= next.C) continue;
else if(A[next.R][next.C] == target_color) {
q.push(next);
}
}
}
}
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;
}