結果

問題 No.460 裏表ちわーわ
ユーザー tailstails
提出日時 2016-12-11 00:49:21
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 24,540 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 03:03:11
合計ジャッジ時間 2,303 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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