結果

問題 No.868 ハイパー部分和問題
ユーザー tailstails
提出日時 2020-11-27 14:05:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 7,000 ms
コード長 1,160 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 64,268 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 04:10:53
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 50 ms
4,376 KB
testcase_15 AC 50 ms
4,380 KB
testcase_16 AC 49 ms
4,376 KB
testcase_17 AC 50 ms
4,376 KB
testcase_18 AC 50 ms
4,376 KB
testcase_19 AC 15 ms
4,380 KB
testcase_20 AC 15 ms
4,376 KB
testcase_21 AC 16 ms
4,380 KB
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 18 ms
4,380 KB
testcase_24 AC 18 ms
4,376 KB
testcase_25 AC 18 ms
4,376 KB
testcase_26 AC 19 ms
4,376 KB
testcase_27 AC 20 ms
4,380 KB
testcase_28 AC 20 ms
4,376 KB
testcase_29 AC 45 ms
4,376 KB
testcase_30 AC 47 ms
4,376 KB
testcase_31 AC 47 ms
4,376 KB
testcase_32 AC 50 ms
4,380 KB
testcase_33 AC 50 ms
4,376 KB
testcase_34 AC 47 ms
4,380 KB
testcase_35 AC 47 ms
4,380 KB
testcase_36 AC 25 ms
4,376 KB
testcase_37 AC 25 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <sys/mman.h>
#include <unistd.h>
#include <bitset>

char*rp;

inline int rd_int(){
	int v=0;
	for(int c;c=*rp++-48,c>=0;)v=v*10+c;
	return v;
}

int n,k;

struct RangeVal {
	int st;
	int ed;
	int val;
};
RangeVal rv[30000],rvtmp[30000];

char wbuf[30000];

typedef std::bitset<15001> bst;

void f(int st,int ed,int l,int r,bst& bs){
	int tmpn=0,wn=l;
	for(int i=l;i<r;++i){
		if(rv[i].ed<=st||ed<=rv[i].st){
			rvtmp[tmpn++]=rv[i];
		}else if(rv[i].st<=st&&ed<=rv[i].ed){
			bs|=bs<<rv[i].val;
			rvtmp[tmpn++]=rv[i];
		}else{
			rv[wn++]=rv[i];
		}
	}
	for(int i=0;i<tmpn;++i){
		rv[wn+i]=rvtmp[i];
	}
	if(st==ed-1){
		wbuf[st*2+0]=bs[k]+48;
		wbuf[st*2+1]=10;
	}else{
		bst bs1=bs;
		f(st,st+ed>>1,l,wn,bs1);
		f(st+ed>>1,ed,l,wn,bs);
	}
}

int main(){
	rp=static_cast<char*>(mmap(0,1l<<28,1,2,0,0));
	n=rd_int();
	k=rd_int();
	for(int i=0;i<n;++i){
		rv[i]={0,15000,rd_int()};
	}
	int q=rd_int();
	for(int i=0;i<q;++i){
		int x=rd_int()-1;
		int v=rd_int();
		rv[n+i]={rv[x].st,i,rv[x].val};
		rv[x]={i,rv[x].ed,v};
	}

	bst bs;
	bs[0]=1;
	f(0,q,0,n+q,bs);
	write(1,wbuf,q*2);
	_exit(0);
}
0