結果

問題 No.2984 [Cherry Anniversary 4] 満開の願いを込めた 27 の桜
ユーザー tailstails
提出日時 2024-12-09 15:28:01
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 4,000 ms
コード長 8,879 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 34,688 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-09 15:28:04
合計ジャッジ時間 2,307 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 10 ms
5,248 KB
testcase_02 AC 11 ms
5,248 KB
testcase_03 AC 10 ms
5,248 KB
testcase_04 AC 8 ms
5,248 KB
testcase_05 AC 9 ms
5,248 KB
testcase_06 AC 9 ms
5,248 KB
testcase_07 AC 10 ms
5,248 KB
testcase_08 AC 10 ms
5,248 KB
testcase_09 AC 10 ms
5,248 KB
testcase_10 AC 11 ms
5,248 KB
testcase_11 AC 10 ms
5,248 KB
testcase_12 AC 10 ms
5,248 KB
testcase_13 AC 11 ms
5,248 KB
testcase_14 AC 11 ms
5,248 KB
testcase_15 AC 10 ms
5,248 KB
testcase_16 AC 10 ms
5,248 KB
testcase_17 AC 10 ms
5,248 KB
testcase_18 AC 11 ms
5,248 KB
testcase_19 AC 10 ms
5,248 KB
testcase_20 AC 10 ms
5,248 KB
testcase_21 AC 0 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:11:1: warning: data definition has no type or storage class
   11 | a[3][3][3],x[3][3],y[3][3],z[3][3];
      | ^
main.c:11:1: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
main.c:11:12: warning: type defaults to ‘int’ in declaration of ‘x’ [-Wimplicit-int]
   11 | a[3][3][3],x[3][3],y[3][3],z[3][3];
      |            ^
main.c:11:20: warning: type defaults to ‘int’ in declaration of ‘y’ [-Wimplicit-int]
   11 | a[3][3][3],x[3][3],y[3][3],z[3][3];
      |                    ^
main.c:11:28: warning: type defaults to ‘int’ in declaration of ‘z’ [-Wimplicit-int]
   11 | a[3][3][3],x[3][3],y[3][3],z[3][3];
      |                            ^
main.c:13:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   13 | f(b,p0,p1,p2,q0,q1,q2,r0,r1,r2){
      | ^
main.c: In function ‘f’:
main.c:13:1: warning: type of ‘b’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘p0’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘p1’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘p2’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘q0’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘q1’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘q2’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘r0’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘r1’ defaults to ‘int’ [-Wimplicit-int]
main.c:13:1: warning: type of ‘r2’ defaults to ‘int’ [-Wimplicit-int]
main.c: In function ‘main’:
main.c:295:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  295 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:296:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  296 |         _exit(0);
      |         ^~~~~
main.c:296:9

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rd_signed() ({int _s=*rp=='-'&&++rp,_v=rd();_s?-_v:_v;})
#define rep(v,e) for(typeof(e)v=0;v<e;++v)
#define repeat(e) for(typeof(e)_=e;_--;)

char wbuf[1<<25],*wp=wbuf;
a[3][3][3],x[3][3],y[3][3],z[3][3];

f(b,p0,p1,p2,q0,q1,q2,r0,r1,r2){
	if(
		a[0][q0][r0]+a[1][q0][r0]+a[2][q0][r0]==x[0][0]&&
		a[0][q0][r1]+a[1][q0][r1]+a[2][q0][r1]==x[0][1]&&
		a[0][q0][r2]+a[1][q0][r2]+a[2][q0][r2]==x[0][2]&&
		a[0][q1][r0]+a[1][q1][r0]+a[2][q1][r0]==x[1][0]&&
		a[0][q1][r1]+a[1][q1][r1]+a[2][q1][r1]==x[1][1]&&
		a[0][q1][r2]+a[1][q1][r2]+a[2][q1][r2]==x[1][2]&&
		a[0][q2][r0]+a[1][q2][r0]+a[2][q2][r0]==x[2][0]&&
		a[0][q2][r1]+a[1][q2][r1]+a[2][q2][r1]==x[2][1]&&
		a[0][q2][r2]+a[1][q2][r2]+a[2][q2][r2]==x[2][2]&&
		a[p0][0][r0]+a[p0][1][r0]+a[p0][2][r0]==y[0][0]&&
		a[p0][0][r1]+a[p0][1][r1]+a[p0][2][r1]==y[0][1]&&
		a[p0][0][r2]+a[p0][1][r2]+a[p0][2][r2]==y[0][2]&&
		a[p1][0][r0]+a[p1][1][r0]+a[p1][2][r0]==y[1][0]&&
		a[p1][0][r1]+a[p1][1][r1]+a[p1][2][r1]==y[1][1]&&
		a[p1][0][r2]+a[p1][1][r2]+a[p1][2][r2]==y[1][2]&&
		a[p2][0][r0]+a[p2][1][r0]+a[p2][2][r0]==y[2][0]&&
		a[p2][0][r1]+a[p2][1][r1]+a[p2][2][r1]==y[2][1]&&
		a[p2][0][r2]+a[p2][1][r2]+a[p2][2][r2]==y[2][2]&&
		a[p0][q0][0]+a[p0][q0][1]+a[p0][q0][2]==z[0][0]&&
		a[p0][q1][0]+a[p0][q1][1]+a[p0][q1][2]==z[0][1]&&
		a[p0][q2][0]+a[p0][q2][1]+a[p0][q2][2]==z[0][2]&&
		a[p1][q0][0]+a[p1][q0][1]+a[p1][q0][2]==z[1][0]&&
		a[p1][q1][0]+a[p1][q1][1]+a[p1][q1][2]==z[1][1]&&
		a[p1][q2][0]+a[p1][q2][1]+a[p1][q2][2]==z[1][2]&&
		a[p2][q0][0]+a[p2][q0][1]+a[p2][q0][2]==z[2][0]&&
		a[p2][q1][0]+a[p2][q1][1]+a[p2][q1][2]==z[2][1]&&
		a[p2][q2][0]+a[p2][q2][1]+a[p2][q2][2]==z[2][2]&&
		1
	){
		*wp++=b+48;
		return 1;
	}
	return 0;
}

int main(){
	rd_init();
	int t=rd();
	repeat(t){
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				for(int k=0;k<3;++k){
					a[i][j][k]=rd_signed();
				}
			}
		}
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				x[i][j]=rd_signed();
			}
		}
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				y[i][j]=rd_signed();
			}
		}
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				z[i][j]=rd_signed();
			}
		}
		f(0, 0,1,2, 0,1,2, 0,1,2)||
		f(1, 0,1,2, 0,1,2, 0,2,1)||
		f(1, 0,1,2, 0,1,2, 1,0,2)||
		f(1, 0,1,2, 0,1,2, 2,1,0)||
		f(1, 0,1,2, 0,2,1, 0,1,2)||
		f(1, 0,1,2, 1,0,2, 0,1,2)||
		f(1, 0,1,2, 2,1,0, 0,1,2)||
		f(1, 0,2,1, 0,1,2, 0,1,2)||
		f(1, 1,0,2, 0,1,2, 0,1,2)||
		f(1, 2,1,0, 0,1,2, 0,1,2)||
		f(2, 0,1,2, 0,1,2, 1,2,0)||
		f(2, 0,1,2, 0,1,2, 2,0,1)||
		f(2, 0,1,2, 0,2,1, 0,2,1)||
		f(2, 0,1,2, 0,2,1, 1,0,2)||
		f(2, 0,1,2, 0,2,1, 2,1,0)||
		f(2, 0,1,2, 1,0,2, 0,2,1)||
		f(2, 0,1,2, 1,0,2, 1,0,2)||
		f(2, 0,1,2, 1,0,2, 2,1,0)||
		f(2, 0,1,2, 1,2,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