結果

問題 No.585 工夫のないパズル
ユーザー %20%20
提出日時 2017-11-01 15:07:02
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 1,051 ms
コンパイル使用メモリ 30,848 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 04:09:15
合計ジャッジ時間 1,192 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: warning: data definition has no type or storage class
    3 | p[100],N;
      | ^
main.c:3:1: warning: type defaults to 'int' in declaration of 'p' [-Wimplicit-int]
main.c:3:8: warning: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
    3 | p[100],N;
      |        ^
main.c:5:1: warning: return type defaults to 'int' [-Wimplicit-int]
    5 | idx(n){
      | ^~~
main.c: In function 'idx':
main.c:5:1: warning: type of 'n' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:11:1: warning: return type defaults to 'int' [-Wimplicit-int]
   11 | yoko(r,a){
      | ^~~~
main.c: In function 'yoko':
main.c:11:1: warning: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c:11:1: warning: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:19:1: warning: return type defaults to 'int' [-Wimplicit-int]
   19 | tate(c,b){
      | ^~~~
main.c: In function 'tate':
main.c:19:1: warning: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:19:1: warning: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:27:1: warning: return type defaults to 'int' [-Wimplicit-int]
   27 | main(i,j){
      | ^~~~
main.c: In function 'main':
main.c:27:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:27:1: warning: type of 'j' defaults to 'int' [-Wimplicit-int]
main.c:28:29: warning: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
   28 |         for(i=0;i<16;++i&3||getchar()){
      |                             ^~~~~~~
main.c:1:1: note: 'getchar' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
  +++ |+#include <stdio.h>
    1 | typedef unsigned long long ull;
main.c:58:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   58 |         printf("%d\n",N);
      |         ^~~~~~
main.c:58:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:58:9: warning: incompatible implicit declaration

ソースコード

diff #

typedef unsigned long long ull;
ull z;
p[100],N;

idx(n){
	int r,i;
	for(i=0;i<16;++i)(z>>4*i&15)==n?r=15-i:0;
	return r;
}

yoko(r,a){
	ull m=0xffff000000000000ull>>16*(r&=3);
	if(a&=3){
		z=~m&z|m&((m&z)>>4*a|(m&z)<<4*(4-a));
		p[N++]=0<<4|r<<2|a;
	}
}

tate(c,b){
	ull m=0xf000f000f000f000ull>>4*(c&=3);
	if(b&=3){
		z=~m&z|m&((m&z)>>16*b|(m&z)<<16*(4-b));
		p[N++]=1<<4|c<<2|b;
	}
}

main(i,j){
	for(i=0;i<16;++i&3||getchar()){
		z=z<<4|getchar()-1&15;
	}
	for(i=0;i<12;++i){
		j=idx(i);
		if(i!=j){
			if((i&3)==(j&3)){
				yoko(j>>2,1);
				j=j&12|j+1&3;
			}
			tate(j,3-(j>>2));
			tate(i,3-(i>>2));
			yoko(3,i-j);
			tate(i,(i>>2)-3);
			tate(j,(j>>2)-3);
		}
	}
	yoko(3,12-idx(12));
	for(i=13;i<15;++i){
		for(j=idx(i);i!=j;--j){
			tate(j,3);
			yoko(3,2);
			tate(j,1);
			yoko(3,1);
			tate(j,3);
			yoko(3,1);
			tate(j,1);
			yoko(3,1);
		}
	}
	printf("%d\n",N);
	for(i=0;i<N;++i)printf("%c %d %d\n","RC"[p[i]>>4],p[i]>>2&3,p[i]&3);
}
0