提交记录 3604


用户 题目 状态 得分 用时 内存 语言 代码长度
consecutivelimit noi17a. 【NOI2017】整数 Accepted 100 722.675 ms 21844 KB C++ 2.47 KB
提交时间 评测时间
2018-07-16 21:18:49 2020-07-31 21:20:39
#include<cstdio>
typedef long long ll;
const int inf=1<<30;
int firz[1<<16];
unsigned A[1<<21];
int T[1<<21][2];
bool tag[1<<21];
#define Def int node,int L,int R
#define Mid (L+R>>1)
#define Ls node<<1,L,Mid
#define Rs node<<1|1,Mid,R
inline int min(int a,int b){return a<b?a:b;}
inline int fir0(unsigned x){return firz[x&65535]<16?firz[x&65535]:firz[x>>16]+16;}
void build(Def){
	T[node][0]=L<<5;
	T[node][1]=inf;
	if(R-L>1)build(Ls),build(Rs);
}
inline void pushup(int node){
	bool ty=tag[node];
	T[node][0]=min(T[node<<1][ty],T[node<<1|1][ty]);
	T[node][1]=min(T[node<<1][!ty],T[node<<1|1][!ty]);
}
unsigned modify(Def,int i,unsigned x,bool ty,bool y=0){
///*noi*/printf("modify [%d,%d) %d %u %d %d\n",L,R,i,x,ty,y);
	if(R-L==1){
		unsigned o=A[i],res;
		if(y)o=~o;
		if(ty){
			res=o<x?1:0;
			o-=x;
		}
		else{
			res=o>~x?1:0;
			o+=x;
		}
		A[i]=y?~o:o;
		(T[node][y]=fir0(o))==32?T[node][y]=inf:T[node][y]+=L<<5;
		(T[node][!y]=fir0(~o))==32?T[node][!y]=inf:T[node][!y]+=L<<5;
///*noi*/printf("T={%d,%d} res=%u\n",T[node][0],T[node][1],res);
		return res;
	}
	y^=tag[node];
	unsigned res=i<Mid?modify(Ls,i,x,ty,y):modify(Rs,i,x,ty,y);
	pushup(node);
	return res;
}
void reverse(Def,int l,int r){
	if(l==L&&r==R){
		if(R-L==1)A[l]=~A[l];
		else tag[node]=!tag[node];
		int t=T[node][0];T[node][0]=T[node][1];T[node][1]=t;
		return;
	}
	if(r<=Mid)reverse(Ls,l,r);
	else if(l>=Mid)reverse(Rs,l,r);
	else reverse(Ls,l,Mid),reverse(Rs,Mid,r);
	pushup(node);
}
int find(Def,int i,bool ty){
	if(T[node][ty]>=inf)return inf;
	if(i==L)return T[node][ty];
	ty^=tag[node];
	if(i>=Mid)return find(Rs,i,ty);
	int x=find(Ls,i,ty);
	if(x<inf)return x;
	return find(Rs,Mid,ty);
}
unsigned query(Def,int i){
///*noi*/printf("query [%d,%d) %d tag=%d\n",L,R,i,tag[node]);
	if(R-L==1)return A[i];
	unsigned x=i<Mid?query(Ls,i):query(Rs,i);
	if(tag[node])x=~x;
	return x;
}
int main(){
	int n,t1,t2,t3;scanf("%d%d%d%d",&n,&t1,&t2,&t3);
	for(int i=1;i<1<<16;i++)firz[i]=i%2?firz[i/2]+1:0;
	build(1,0,1<<20);
	while(n--){
		int op;scanf("%d",&op);
		if(op==1){
			int a,b;scanf("%d%d",&a,&b);
			int k=b>>5,pos=b&31;
			bool neg=(a<0);
			if(neg)a=-a;
			unsigned vl=(unsigned)(((ll)a)<<pos),vr=(unsigned)(((ll)a)>>32-pos);
			if(vl)vr+=modify(1,0,1<<20,k,vl,neg);
			if(vr&&modify(1,0,1<<20,k+1,vr,neg)){
				int fir=find(1,0,1<<20,k+2,neg);
				if(k+2<fir/32)reverse(1,0,1<<20,k+2,fir/32);
				modify(1,0,1<<20,fir/32,1,neg);
			}
		}
		else{
			int k,s;scanf("%d",&k);
			s=query(1,0,1<<20,k>>5)>>(k&31)&1;
			printf("%d\n",s);
		}
	}
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #14.303 ms16 MB + 280 KBAcceptedScore: 4

Testcase #24.363 ms16 MB + 280 KBAcceptedScore: 4

Testcase #35.129 ms16 MB + 280 KBAcceptedScore: 4

Testcase #45.584 ms16 MB + 280 KBAcceptedScore: 4

Testcase #58.258 ms16 MB + 304 KBAcceptedScore: 4

Testcase #67.582 ms16 MB + 308 KBAcceptedScore: 4

Testcase #710.099 ms16 MB + 352 KBAcceptedScore: 4

Testcase #810.494 ms16 MB + 312 KBAcceptedScore: 4

Testcase #923.45 ms16 MB + 456 KBAcceptedScore: 4

Testcase #1037.076 ms16 MB + 396 KBAcceptedScore: 4

Testcase #1140.899 ms16 MB + 356 KBAcceptedScore: 4

Testcase #1233.172 ms16 MB + 632 KBAcceptedScore: 4

Testcase #1350.021 ms16 MB + 668 KBAcceptedScore: 4

Testcase #14138.544 ms17 MB + 304 KBAcceptedScore: 4

Testcase #15143.601 ms17 MB + 824 KBAcceptedScore: 4

Testcase #16278.092 ms18 MB + 312 KBAcceptedScore: 4

Testcase #17307.343 ms16 MB + 680 KBAcceptedScore: 4

Testcase #18428.838 ms19 MB + 328 KBAcceptedScore: 4

Testcase #19492.225 ms19 MB + 844 KBAcceptedScore: 4

Testcase #20339.058 ms19 MB + 916 KBAcceptedScore: 4

Testcase #21446.748 ms20 MB + 852 KBAcceptedScore: 4

Testcase #22575.656 ms16 MB + 996 KBAcceptedScore: 4

Testcase #23674.761 ms17 MB + 644 KBAcceptedScore: 4

Testcase #24606.709 ms17 MB + 20 KBAcceptedScore: 4

Testcase #25722.675 ms21 MB + 340 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2024-11-22 12:45:05 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠