結果

問題 No.2220 Range Insert & Point Mex
ユーザー tailstails
提出日時 2023-02-18 13:19:14
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 1,860 bytes
コンパイル時間 1,261 ms
コンパイル使用メモリ 30,732 KB
実行使用メモリ 11,844 KB
最終ジャッジ日時 2023-09-28 18:20:03
合計ジャッジ時間 4,073 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 14 ms
11,844 KB
testcase_14 AC 14 ms
11,776 KB
testcase_15 AC 15 ms
11,796 KB
testcase_16 AC 15 ms
11,808 KB
testcase_17 AC 15 ms
11,804 KB
testcase_18 AC 14 ms
11,832 KB
testcase_19 AC 14 ms
11,836 KB
testcase_20 AC 8 ms
9,452 KB
testcase_21 AC 8 ms
9,384 KB
testcase_22 AC 8 ms
9,476 KB
testcase_23 AC 14 ms
11,820 KB
testcase_24 AC 12 ms
10,784 KB
testcase_25 AC 10 ms
9,584 KB
testcase_26 AC 13 ms
11,436 KB
testcase_27 AC 8 ms
7,800 KB
testcase_28 AC 5 ms
6,132 KB
testcase_29 AC 5 ms
6,484 KB
testcase_30 AC 5 ms
6,536 KB
testcase_31 AC 11 ms
10,960 KB
testcase_32 AC 8 ms
9,128 KB
testcase_33 AC 8 ms
9,060 KB
testcase_34 AC 11 ms
10,104 KB
testcase_35 AC 10 ms
10,172 KB
testcase_36 AC 10 ms
9,888 KB
testcase_37 AC 10 ms
9,848 KB
testcase_38 AC 12 ms
11,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:119:3: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
   write(1,wp,wbuf+sizeof wbuf-wp);
   ^~~~~
main.c:121:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:121:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

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

#define getrp() ({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#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);})
#define rep(v,e) for(long v=0;v<e;++v)
#define rrep(v,e) for(long v=e;v--;)
#define ctz __builtin_ctzl

typedef unsigned long ulong;
char wbuf[1<<25];

void sort_aux(ulong*a,ulong*b,int n,int ph){
	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=0;i<256;++i){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	if(ph==0){
		for(int i=0;i<n;++i){
			b[c[a[i]&255]++]=a[i]>>8|a[i]<<56;
		}
	}else{
		for(int i=0;i<n;++i){
			b[c[a[i]&255]++]=a[i]>>40|a[i]<<24;
		}
	}
}

void sort(ulong*a,int n){
	ulong*b=a+n;
	sort_aux(a,b,n,0);
	sort_aux(b,a,n,0);
	sort_aux(a,b,n,0);
	sort_aux(b,a,n,1);
}

ulong e[300000*2];

ulong b0,b1[1<<6],b2[1<<12];

void initb(){
	b0=~0ul;
	rep(i,1<<6){
		b1[i]=~0ul;
	}
	rep(i,1<<12){
		b2[i]=~0ul;
	}
}

int c[100000];
int r[100000];

int main(){
	char*rp=getrp();
	long n=rd();
	long j=0;
	rep(i,n){
		long l=rd();
		long r=rd();
		long a=rd();
		if(a<100000){
			e[j++]=a<<32|l<<2|0;
			e[j++]=a<<32|r<<2|2;
		}
	}
	long q=rd();
	rep(i,q){
		long x=rd();
		e[j++]=i<<32|x<<2|1;
	}
	sort(e,j);

	initb();
	
	rep(i,j){
		long t=e[i]&3;
		long a=e[i]>>32;
		if(t==0){
			if(!c[a]++){
				if(!(b2[a>>6]&=~(1ul<<a))){
					if(!(b1[a>>12]&=~(1ul<<(a>>6)))){
						b0&=~(1ul<<(a>>12));
					}
				}
			}
		}
		if(t==1){
			long d=ctz(b0);
			d=d<<6|ctz(b1[d]);
			d=d<<6|ctz(b2[d]);
			r[a]=d;
		}
		if(t==2){
			if(!--c[a]){
				b2[a>>6]|=1ul<<a;
				b1[a>>12]|=1ul<<(a>>6);
				b0|=1ul<<(a>>12);
			}
		}
	}

	{
		char*wp=wbuf+sizeof wbuf;
		rrep(i,q){
			*--wp='\n';
			wt(r[i]);
		}
		write(1,wp,wbuf+sizeof wbuf-wp);
	}
	_exit(0);
}
0