結果

問題 No.421 しろくろチョコレート
コンテスト
ユーザー 👑 tails
提出日時 2016-09-10 00:12:04
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 745 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 155 ms
コンパイル使用メモリ 30,976 KB
最終ジャッジ日時 2026-02-23 22:20:59
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47 WA * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | a[52][52];
      | ^
main.c:2:1: warning: data definition has no type or storage class
    2 | s;
      | ^
main.c:4:1: warning: data definition has no type or storage class
    4 | o[2];p[2];
      | ^
main.c:4:6: warning: data definition has no type or storage class
    4 | o[2];p[2];
      |      ^
main.c: In function ‘main’:
main.c:17:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   17 |         scanf("%d%d",&n,&m);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | a[52][52];
main.c:20:34: warning: format ‘%c’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Wformat=]
   20 |                         scanf(" %c",&a[y+1][x+1]);
      |                                 ~^  ~~~~~~~~~~~~
      |                                  |  |
      |                                  |  int *
      |                                  char *
      |                                 %lc
main.c:47:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   47 |         printf("%d",s);
      |         ^~~~~~
main.c:47:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’

ソースコード

diff #
raw source code

a[52][52];
s;

o[2];p[2];
f(y,x){
	if(a[y][x]){
		a[y][x]=0;
		++o[y+x&1];
		f(y-1,x);
		f(y+1,x);
		f(y,x-1);
		f(y,x+1);
	}
}

main(m,n,x,y,c,q,t){
	scanf("%d%d",&n,&m);
	for(y=0;y<n;++y){
		for(x=0;x<m;++x){
			scanf(" %c",&a[y+1][x+1]);
			a[y+1][x+1]>>=6;
		}
	}
	do{
		q=0;
		for(y=0;y<n;++y){
			for(x=0;x<m;++x){
				if(a[y+1][x+1]){
					c=a[y+0][x+1]+a[y+2][x+1]+a[y+1][x+0]+a[y+1][x+2];
					if(c==1){
						q=1;s+=100;
						a[y+0][x+1]=a[y+2][x+1]=a[y+1][x+0]=a[y+1][x+2]=a[y+1][x+1]=0;
					}
				}
			}
		}
	}while(q);
	for(y=0;y<n;++y){
		for(x=0;x<m;++x){
			o[0]=o[1]=0;
			f(y+1,x+1);
			s+=100*(t=o[0]<o[1]?o[0]:o[1]);
			p[0]+=o[0]-t;p[1]+=o[1]-t;
		}
	}
	s+=8*(p[0]<p[1]?p[0]:p[1])+p[0]+p[1];
	printf("%d",s);
	return 0;
}
0