結果
| 問題 |
No.179 塗り分け
|
| ユーザー |
notetonous
|
| 提出日時 | 2016-06-16 01:17:46 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,195 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 22,144 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-03 03:26:11 |
| 合計ジャッジ時間 | 1,327 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 28 WA * 12 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:40:27: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[50]’ [-Wformat=]
40 | for(i=0;i<H;i++)scanf("%s",&s[i]);
| ~^ ~~~~~
| | |
| | char (*)[50]
| char *
main.c:39:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d %d",&H,&W);
| ^~~~~~~~~~~~~~~~~~~~
main.c:40:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | for(i=0;i<H;i++)scanf("%s",&s[i]);
| ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int H,W;
char s[50][50];
char tmp[50][50];
int color(int di,int dj){
int i,j;
for(i=0;i<H;i++){
for(j=0;j<W;j++){
if(tmp[i][j]=='#'){
if(tmp[i+di][j+dj]=='#' && i+di<=H && j+dj<=W)tmp[i][j]=tmp[i+di][j+dj]='.';
else return 0;
}
}
}
return 1;
}
void init(){
int i,j;
for(i=0;i<H;i++){
for(j=0;j<W;j++){
tmp[i][j]=s[i][j];
}
}
}
void print(){
int i,j;
for(i=0;i<H;i++){
for(j=0;j<W;j++){
printf("%c",tmp[i][j]);
}
printf("\n");
}
}
int main(){
int i,j;
int di,dj;
int flag=0;
scanf("%d %d",&H,&W);
for(i=0;i<H;i++)scanf("%s",&s[i]);
for(i=0;i<H;i++){
for(j=0;j<W;j++){
if(s[i][j]=='#')flag=1;
}
}
if(flag=0){
printf("NO\n");
return 0;
}
init();
di=0;
for(dj=1;dj<W;dj++){
// printf("%d %d\n",di,dj);
if(color(di,dj)==1){
printf("YES\n");
//print();
return 0;
}
//print();
init();
}
for(di=1;di<H;di++){
for(dj=-W+1;dj<W;dj++){
//printf("%d %d\n",di,dj);
if(color(di,dj)==1){
printf("YES\n");
//print();
return 0;
}
// print();
init();
}
}
printf("NO\n");
return 0;
}
notetonous