結果

問題 No.2212 One XOR Matrix
ユーザー tailstails
提出日時 2023-02-15 18:23:32
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,384 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 33,152 KB
実行使用メモリ 9,668 KB
最終ジャッジ日時 2024-07-18 02:39:51
合計ジャッジ時間 2,164 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 0 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 0 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 9 ms
9,668 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘mkwd’:
main.c:13:20: warning: multi-character character constant [-Wmultichar]
   13 |         unsigned v='0000';
      |                    ^~~~~~
main.c: At top level:
main.c:33:7: warning: type defaults to ‘int’ in declaration of ‘a4x4’ [-Wimplicit-int]
   33 | const a4x4[4][4]={
      |       ^~~~
main.c: In function ‘main’:
main.c:47:17: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
   47 |                 read(0,rbuf,sizeof rbuf);
      |                 ^~~~
main.c:52:17: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   52 |                 printf("-1");
      |                 ^~~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
  +++ |+#include <stdio.h>
    1 | #pragma GCC optimize("Ofast")
main.c:52:17: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   52 |                 printf("-1");
      |                 ^~~~~~
main.c:52:17: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:53:17: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
   53 |                 exit(0);
      |                 ^~~~
main.c:1:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
  +++ |+#include <stdlib.h>
    1 | #pragma GCC optimize("Ofast")
main.c:53:17: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
   53 |                 exit(0);
      |                 ^~~~
main.c:53:17: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
main.c:93:17: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
   93 |                 write(1,wp,wbuf+sizeof wbuf-wp);
      |                 ^~~~~
main.c:95:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-functio

ソースコード

diff #

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

#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(long v=0;v<e;++v)
#define rep4(v,s,e,t) for(long v=s;v<e;v+=t)

char wbuf[1<<25];
unsigned wd[10000];
char wdlz[10000];

void mkwd(){
	unsigned v='0000';
	long i=0;
	rep(a,10){
		rep(b,10){
			rep(c,10){
				rep(d,10){
					wd[i++]=v;
					v+=1<<24;
				}
				v+=(1<<16)-(10<<24);
			}
			v+=(1<<8)-(10<<16);
		}
		v+=(1<<0)-(10<<8);
	}
	rep(j,1000) wdlz[j]=1;
	rep(j,100) wdlz[j]=2;
	rep(j,10) wdlz[j]=3;
}

const a4x4[4][4]={
{7,14,0,8},
{4,12,2,11},
{15,9,6,1},
{13,10,5,3},
};

int a[4][1024];

int main(){
	mkwd();
	int n;
	{
		char rbuf[64];
		read(0,rbuf,sizeof rbuf);
		char*rp=rbuf;
		n=rd();
	}
	if(n==1){
		printf("-1");
		exit(0);
	}
	int w=1<<n;
	{
		char*wp=wbuf+sizeof wbuf;
		int o=0;
		rep4(j,0,w,4){
			rep4(i,0,w,4){
				if(i==j){
					rep(y,4){
						rep(x,4){
							a[y][i+x]=o+a4x4[y][x];
						}
					}
					o+=16;
				}else{
					rep(y,4){
						rep(x,4){
							a[y][i+x]=o++;
						}
					}
				}
			}
			rep(y,4){
				*--wp='\n';
				rep(x,w){
					unsigned v=a[y][x];
					if(v>=10000){
						wp-=4;
						*(unsigned*)wp=wd[v%10000];
						v/=10000;
					}
					wp-=4;
					*(unsigned*)wp=wd[v];
					wp+=wdlz[v];
					*--wp=' ';
				}
				++wp;
			}
		}
		write(1,wp,wbuf+sizeof wbuf-wp);
	}
	_exit(0);
}
0