結果

問題 No.2094 Symmetry
ユーザー tailstails
提出日時 2022-10-08 01:54:25
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,477 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 31,872 KB
実行使用メモリ 7,124 KB
最終ジャッジ日時 2023-09-03 19:36:11
合計ジャッジ時間 5,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 11 ms
6,684 KB
testcase_10 AC 10 ms
6,620 KB
testcase_11 AC 10 ms
6,748 KB
testcase_12 AC 10 ms
6,628 KB
testcase_13 AC 9 ms
6,688 KB
testcase_14 AC 10 ms
6,768 KB
testcase_15 AC 10 ms
6,624 KB
testcase_16 AC 10 ms
6,756 KB
testcase_17 AC 9 ms
6,684 KB
testcase_18 AC 9 ms
6,624 KB
testcase_19 AC 11 ms
6,748 KB
testcase_20 AC 11 ms
6,716 KB
testcase_21 AC 10 ms
6,712 KB
testcase_22 AC 11 ms
6,676 KB
testcase_23 AC 9 ms
6,752 KB
testcase_24 AC 9 ms
6,620 KB
testcase_25 AC 10 ms
6,684 KB
testcase_26 AC 10 ms
6,620 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 11 ms
6,920 KB
testcase_29 AC 0 ms
4,380 KB
testcase_30 AC 11 ms
7,068 KB
testcase_31 AC 12 ms
6,824 KB
testcase_32 AC 11 ms
7,124 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 11 ms
5,920 KB
testcase_35 AC 10 ms
5,232 KB
testcase_36 AC 7 ms
5,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:77:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wp,wbuf+sizeof wbuf-wp);
  ^~~~~
main.c:78:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:78:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

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 rd_signed(v) ({int _v=0,_c,_s;_s=*rp=='-'&&++rp;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_s?-_v:_v;})
#define wt(v) {ulong _z=v;do*--wp=_z%10+48;while(_z/=10);}
#define rep(v,e) for(long v=0;v<e;++v)
#define rrep(v,e) for(long v=e;v--;)

typedef unsigned long ulong;

void radix_sort_aux(unsigned*a,unsigned*b,int n){
	int c[256];
	for(int i=0;i<256;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		++c[a[i]&255];
	}
	int t=0;
	for(int i=256;i--;){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	for(int i=0;i<n;++i){
		b[c[a[i]&255]++]=a[i]>>8|a[i]<<24;
	}
}

void radix_sort(unsigned*a,int n){
	static unsigned b[500*500];
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
}

int c1[500*500],c2[250*500];

int main(){
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	long n=rd();
	long k=rd();
	long b=0;
	rrep(i,(n*2)*(n*2+1)){
		b+=*rp++&1;
	}
	rep(y,n*2){
		rep(x,n){
			int c=rd_signed();
			c1[n*2*y+x]=c^1<<31;
		}
		rep(x,n){
			int c=rd_signed();
			c1[n*2*y+n+x]=c^1<<31;
			c2[n*y+n+~x]=c+c1[n*2*y+n+~x];
		}
	}
	radix_sort(c1,(n*2)*(n*2));
	long z=0;
	rep(i,b){
		z+=c1[i]^1<<31;
	}
	if(!(b&1)){
		radix_sort(c2,n*(n*2));
		b>>=1;
		rep(i,b){
			k+=c2[i]^1<<31;
		}
		z=z>=k?z:k;
	}
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(z<0?-z:z);
	if(z<0)*--wp='-';
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0