結果

問題 No.1082 XORのXOR
コンテスト
ユーザー 👑 tails
提出日時 2020-11-09 21:26:37
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 883 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 122 ms
コンパイル使用メモリ 28,796 KB
最終ジャッジ日時 2026-02-22 06:20:24
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'sort1b':
main.c:9:5: warning: old-style function definition [-Wold-style-definition]
    9 | int sort1b(b,l,r){
      |     ^~~~~~
main.c:9:5: error: type of 'b' defaults to 'int' [-Wimplicit-int]
main.c:9:5: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:9:5: error: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:28:1: error: return type defaults to 'int' [-Wimplicit-int]
   28 | f(p,al,ar,bl,br){
      | ^
main.c: In function 'f':
main.c:28:1: warning: old-style function definition [-Wold-style-definition]
main.c:28:1: error: type of 'p' defaults to 'int' [-Wimplicit-int]
main.c:28:1: error: type of 'al' defaults to 'int' [-Wimplicit-int]
main.c:28:1: error: type of 'ar' defaults to 'int' [-Wimplicit-int]
main.c:28:1: error: type of 'bl' defaults to 'int' [-Wimplicit-int]
main.c:28:1: error: type of 'br' defaults to 'int' [-Wimplicit-int]
main.c:29:27: error: 'return' with no value, in function returning non-void [-Wreturn-mismatch]
   29 |         if(al==ar|bl==br) return;
      |                           ^~~~~~
main.c:28:1: note: declared here
   28 | f(p,al,ar,bl,br){
      | ^
main.c:34:17: error: 'return' with no value, in function returning non-void [-Wreturn-mismatch]
   34 |                 return;
      |                 ^~~~~~
main.c:28:1: note: declared here
   28 | f(p,al,ar,bl,br){
      | ^
main.c: At top level:
main.c:47:1: error: return type defaults to 'int' [-Wimplicit-int]
   47 | main(){
      | ^~~~
main.c: In function 'main':
main.c:48:17: error: too many arguments to function 'mmap'; expected 0, have 6
   48 |         char*rp=mmap(0l,11l*2001,1,2,0,0ll);
      |                 ^~~~ ~~
main.c:4:6: note: declared here
    4 | char*mmap();
      |      ^~~~
main.c:57:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   57 |         printf("%d",maxv);
      |         ^~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf

ソースコード

diff #
raw source code

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

char*mmap();
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

int a[2000];

int sort1b(b,l,r){
	int ml=l;
	int mr=r;
	while(1){
		while(ml<mr&&!(a[ml]&b)){
			++ml;
		}
		while(ml<mr&&(a[mr-1]&b)){
			--mr;
		}
		if(ml==mr) return ml;
		int t=a[ml];
		a[ml]=a[mr-1];
		a[mr-1]=t;
	}
}

int maxv;

f(p,al,ar,bl,br){
	if(al==ar|bl==br) return;
	if(p<0) {
		if(maxv<(a[al]^a[bl])){
			maxv=a[al]^a[bl];
		}
		return;
	}
	int b=1<<p;
	int am=sort1b(b,al,ar);
	int bm=sort1b(b,bl,br);
	if(am==al&bm==bl|am==ar&bm==br){
		f(p-1,al,ar,bl,br);
	}else{
		f(p-1,al,am,bm,br);
		f(p-1,am,ar,bl,bm);
	}
}

main(){
	char*rp=mmap(0l,11l*2001,1,2,0,0ll);
	RD(n);
	for(int i=0;i<n;++i){
		RD(t); a[i]=t;
	}
	int p=29;
	int m;
	while(p>=0&&(m=sort1b(1<<p,0,n),m==0|m==n))--p;
	if(p>=0) f(p-1,0,m,m,n);
	printf("%d",maxv);
}
0