提交记录 3462


用户 题目 状态 得分 用时 内存 语言 代码长度
zhouyuyang noi17a. 【NOI2017】整数 Accepted 100 440.277 ms 36048 KB C++ 1.54 KB
提交时间 评测时间
2018-07-15 18:47:29 2020-07-31 21:18:14
#include<cmath>
#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 #1603.19 us7 MB + 192 KBAcceptedScore: 4

Testcase #2620.69 us7 MB + 192 KBAcceptedScore: 4

Testcase #31.017 ms7 MB + 212 KBAcceptedScore: 4

Testcase #4942.72 us7 MB + 232 KBAcceptedScore: 4

Testcase #52.26 ms7 MB + 280 KBAcceptedScore: 4

Testcase #61.192 ms7 MB + 284 KBAcceptedScore: 4

Testcase #73.387 ms7 MB + 564 KBAcceptedScore: 4

Testcase #83.297 ms7 MB + 368 KBAcceptedScore: 4

Testcase #910.487 ms8 MB + 436 KBAcceptedScore: 4

Testcase #1015.753 ms8 MB + 484 KBAcceptedScore: 4

Testcase #1116.883 ms8 MB + 252 KBAcceptedScore: 4

Testcase #127.788 ms8 MB + 864 KBAcceptedScore: 4

Testcase #1324.212 ms10 MB + 76 KBAcceptedScore: 4

Testcase #1471.575 ms14 MB + 600 KBAcceptedScore: 4

Testcase #1538.817 ms13 MB + 996 KBAcceptedScore: 4

Testcase #16153.366 ms19 MB + 776 KBAcceptedScore: 4

Testcase #17143.314 ms11 MB + 252 KBAcceptedScore: 4

Testcase #18245.332 ms24 MB + 940 KBAcceptedScore: 4

Testcase #19290.327 ms27 MB + 504 KBAcceptedScore: 4

Testcase #20385.695 ms29 MB + 92 KBAcceptedScore: 4

Testcase #21151.994 ms23 MB + 84 KBAcceptedScore: 4

Testcase #22272.773 ms12 MB + 840 KBAcceptedScore: 4

Testcase #23327.237 ms18 MB + 420 KBAcceptedScore: 4

Testcase #24289.305 ms13 MB + 48 KBAcceptedScore: 4

Testcase #25440.277 ms35 MB + 208 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2024-04-25 06:54:37 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用