提交记录 3461


用户 题目 状态 得分 用时 内存 语言 代码长度
zhouyuyang noi17a. 【NOI2017】整数 Accepted 100 440.8 ms 36048 KB C++ 1.53 KB
提交时间 评测时间
2018-07-15 18:46:24 2020-07-31 21:18:08
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<set>
#define N 30000005
using namespace std;
const int L=2333333;
char LZH[L],*S=LZH,*T=LZH;
inline char gc(){
	if (S==T){
		T=(S=LZH)+fread(LZH,1,L,stdin);
		if (S==T) return EOF;
	}
	return *S++;
}
inline int read(){
	char ch=gc();
	int x=0,f=1;
	for (;ch<'0'||ch>'9';ch=gc())
		if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())
		x=x*10-48+ch;
	return x*f;
}
int n,x,y;
bool fl;
bitset<N> a,b;
struct CMP{
	bool operator ()(const int &x,const int &y){
		return x>y;
	}
};
struct SET{
	int cnt[(N>>4)+1];
	set<int,CMP> s;
	SET(){
		s.insert(-1);
		memset(cnt,0,sizeof(cnt));
	}
	void insert(int x){
		x+=16; x>>=4;
		if (!(cnt[x]++)) s.insert(x);
	}
	void erase(int x){
		x+=16; x>>=4;
		if (!(--cnt[x])) s.erase(x);
	}
	int query(int x){
		if (x<0) return -2;
		for (int i=x;i>=((x>>4)<<4)&&i>=0;i--)
			if (a[i]^b[i]) return i;
		int y=*s.lower_bound(x>>4);
		if (y==-1) return -2; y=(y-1)<<4;
		for (int i=y+15;i>=y&&i>=0;i--)
			if (a[i]^b[i]) return i;
		return -2;	
	}
}Set;
void add(){
	register bool tg=0;
	for (register int i=y;tg||x;i++,x>>=1)
		if (tg^(x&1)){
			a[i]^b[i]?Set.erase(i):Set.insert(i);
			tg=(fl?a[i]:b[i]);
			fl?a[i]=1-a[i]:b[i]=1-b[i];
		}
		else
			tg&=(x&1);
}
int main(){
	n=read(); read(); read(); read();
	Set.insert(-2);
	for (int i=1;i<=n;i++)
		if (read()==1){
			x=read(); y=read();
			fl=(x>0); x=(x>0?x:-x);
			add();
		}
	else{
		x=read();
		y=Set.query(x-1);
		putchar((a[x]^b[x]^(y!=-2&&!a[y]))+'0');
		puts("");
	}
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1602.36 us7 MB + 192 KBAcceptedScore: 4

Testcase #2622.09 us7 MB + 192 KBAcceptedScore: 4

Testcase #31.018 ms7 MB + 212 KBAcceptedScore: 4

Testcase #4943.31 us7 MB + 232 KBAcceptedScore: 4

Testcase #52.258 ms7 MB + 280 KBAcceptedScore: 4

Testcase #61.192 ms7 MB + 284 KBAcceptedScore: 4

Testcase #73.385 ms7 MB + 564 KBAcceptedScore: 4

Testcase #83.301 ms7 MB + 368 KBAcceptedScore: 4

Testcase #910.389 ms8 MB + 436 KBAcceptedScore: 4

Testcase #1015.678 ms8 MB + 484 KBAcceptedScore: 4

Testcase #1116.961 ms8 MB + 252 KBAcceptedScore: 4

Testcase #127.697 ms8 MB + 864 KBAcceptedScore: 4

Testcase #1324.2 ms10 MB + 76 KBAcceptedScore: 4

Testcase #1471.532 ms14 MB + 600 KBAcceptedScore: 4

Testcase #1538.814 ms13 MB + 996 KBAcceptedScore: 4

Testcase #16153.295 ms19 MB + 776 KBAcceptedScore: 4

Testcase #17143.095 ms11 MB + 252 KBAcceptedScore: 4

Testcase #18245.645 ms24 MB + 940 KBAcceptedScore: 4

Testcase #19290.289 ms27 MB + 504 KBAcceptedScore: 4

Testcase #20385.661 ms29 MB + 92 KBAcceptedScore: 4

Testcase #21152.14 ms23 MB + 84 KBAcceptedScore: 4

Testcase #22272.688 ms12 MB + 840 KBAcceptedScore: 4

Testcase #23327.077 ms18 MB + 420 KBAcceptedScore: 4

Testcase #24289.989 ms13 MB + 48 KBAcceptedScore: 4

Testcase #25440.8 ms35 MB + 208 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-18 14:34:52 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠