結果

問題 No.2779 Don't make Pair
コンテスト
ユーザー 👑 tails
提出日時 2024-06-10 10:14:03
言語 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
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,132 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 619 ms
コンパイル使用メモリ 40,348 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-23 16:01:43
合計ジャッジ時間 2,368 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:47:17: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   47 |                 write(1,"0\n\n",3);
      |                 ^~~~~
main.c:48:17: warning: implicit declaration of function '_exit' [-Wimplicit-function-declaration]
   48 |                 _exit(0);
      |                 ^~~~~
main.c:48:17: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]
main.c:62:9: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]
   62 |         _exit(0);
      |         ^~~~~

ソースコード

diff #
raw source code

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) {unsigned _z=v,_n=0;long _d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;}
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define reps(v,s,e) for(typeof(e) v=s;v<e;++v)
#define chmin(v,a) (v=v<=a?v:a)
#define chmax(v,a) (v=v>=a?v:a)

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

int hash_find(unsigned x){
	int h=x&HASH_MASK;
	while(1){
		if(hash[h]==0||hash[h]==x){
			return h;
		}
		h=h+1&HASH_MASK;
	}
}

int b[HASH_N];
char wbuf[1<<25];

int main(){
	rd_init();
	int n=rd();
	int l=0;
	int r=n-1;
	rep(i,n){
		unsigned a=rd();
		int h=hash_find(a);
		if(!hash[h]){
			hash[h]=a;
		}else{
			chmin(r,i);
			chmax(l,b[h]);
		}
		b[h]=i;
	}
	if(l>=r){
		write(1,"0\n\n",3);
		_exit(0);
	}
	char*wp=wbuf;
	{
		unsigned v=r-l;
		wt(v);
	}
	*wp++='\n';
	reps(i,l,r){
		unsigned v=i+1;
		wt(v);
		*wp++=' ';
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0