結果

問題 No.460 裏表ちわーわ
ユーザー tailstails
提出日時 2016-12-11 00:49:21
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-06 03:55:04
合計ジャッジ時間 1,609 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 10 ms
5,376 KB
testcase_07 AC 12 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 12 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 13 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 12 ms
5,376 KB
testcase_23 AC 12 ms
5,376 KB
testcase_24 AC 13 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 0 ms
5,376 KB
testcase_27 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | m;n;b;a[9][9];
      | ^
main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘m’ [-Wimplicit-int]
main.c:1:3: warning: data definition has no type or storage class
    1 | m;n;b;a[9][9];
      |   ^
main.c:1:3: warning: type defaults to ‘int’ in declaration of ‘n’ [-Wimplicit-int]
main.c:1:5: warning: data definition has no type or storage class
    1 | m;n;b;a[9][9];
      |     ^
main.c:1:5: warning: type defaults to ‘int’ in declaration of ‘b’ [-Wimplicit-int]
main.c:1:7: warning: data definition has no type or storage class
    1 | m;n;b;a[9][9];
      |       ^
main.c:1:7: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
main.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    3 | d(y,x,j,i){
      | ^
main.c: In function ‘d’:
main.c:3:1: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int]
main.c:3:1: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
main.c:3:1: warning: type of ‘j’ defaults to ‘int’ [-Wimplicit-int]
main.c:3:1: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:15:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   15 | f(y,x,c,j,i){
      | ^
main.c: In function ‘f’:
main.c:15:1: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int]
main.c:15:1: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
main.c:15:1: warning: type of ‘c’ defaults to ‘int’ [-Wimplicit-int]
main.c:15:1: warning: type of ‘j’ defaults to ‘int’ [-Wimplicit-int]
main.c:15:1: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
main.c:24:41: warning: ‘return’ with no value, in function returning non-void
   24 |                                         return;
      |                                         ^~~~~~
main.c:15:1: note: declared here
   15 | f(y,x,c,j,i){
    

ソースコード

diff #

m;n;b;a[9][9];

d(y,x,j,i){
	for(j=y-1;j<=y+1;++j){
		if(j>=0&&j<m){
			for(i=x-1;i<=x+1;++i){
				if(i>=0&&i<n){
					a[j][i]^=1;
				}
			}
		}
	}
}

f(y,x,c,j,i){
	if(x==n){
		x=0;
		++y;
	}
	if(y==m){
		for(j=0;j<m;++j){
			for(i=0;i<n;++i){
				if(a[j][i]){
					return;
				}
			}
		}
		if(b>c){
			b=c;
		}
		return;
	}

	if(y>0&&x>0){
		if(a[y-1][x-1]){
			d(y,x);
			f(y,x+1,c+1);
			d(y,x);
		}else{
			f(y,x+1,c);
		}
	}else{
		f(y,x+1,c);
		d(y,x);
		f(y,x+1,c+1);
		d(y,x);
	}
}		

main(y,x,j,i){
	scanf("%d%d",&m,&n);
	for(y=0;y<m;++y){
		for(x=0;x<n;++x){
			scanf("%d",&a[y][x]);
		}
	}
	b=99;
	f(0,0,0);
	if(b==99){
		puts("Impossible");
	}else{
		printf("%d",b);
	}
	return 0;
}
0