結果

問題 No.1072 A Nice XOR Pair
ユーザー tailstails
提出日時 2022-10-13 20:41:13
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 857 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 25,744 KB
実行使用メモリ 5,348 KB
最終ジャッジ日時 2023-09-08 19:13:36
合計ジャッジ時間 2,614 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,388 KB
testcase_03 AC 0 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 12 ms
5,348 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 4 ms
4,388 KB
testcase_10 AC 6 ms
5,076 KB
testcase_11 AC 6 ms
4,384 KB
testcase_12 AC 10 ms
4,932 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:45:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wp,wbuf+sizeof wbuf-wp);
  ^~~~~
main.c:46:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:46:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

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

#define rd_skip() while(*rp++>=48)
#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) {ulong _z=v;do*--wp=_z%10+48;while(_z/=10);}

typedef unsigned long ulong;

#define HASH_BITS 18
#define HASH_MASK ((1<<HASH_BITS)-1)
unsigned hash[1<<HASH_BITS];
unsigned d[1<<HASH_BITS];

int main(){
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd_skip();
	unsigned x=rd();
	ulong z=0;
	while(*rp){
		unsigned a=rd();
		{
			ulong h=a&HASH_MASK;
			while(hash[h]!=0&&hash[h]!=a+1){
				h=h+1&HASH_MASK;
			}
			if(hash[h]){
				z+=d[h];
			}
		}
		a^=x;
		{
			ulong h=a&HASH_MASK;
			while(hash[h]!=0&&hash[h]!=a+1){
				h=h+1&HASH_MASK;
			}
			hash[h]=a+1;
			d[h]+=1;
		}
	}

	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(z);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0