結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2022-10-13 20:41:13 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 705 ms |
| コンパイル使用メモリ | 23,552 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 12:08:42 |
| 合計ジャッジ時間 | 1,537 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:45:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
45 | write(1,wp,wbuf+sizeof wbuf-wp);
| ^~~~~
main.c:46:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
46 | _exit(0);
| ^~~~~
main.c:46:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
ソースコード
#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);
}
tails