提交记录 9582


用户 题目 状态 得分 用时 内存 语言 代码长度
AThousandMoon noi17a. 【NOI2017】整数 Accepted 100 812.491 ms 32644 KB C++ 3.14 KB
提交时间 评测时间
2019-06-11 14:04:57 2020-08-01 01:40:56
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int len = 1e6, N = (len + 10) << 2, inf = (1 << 30) - 1;
int sor[N], sand[N], tag[N];
inline void pushup(int x){
	sor[x] = sor[x << 1] | sor[x << 1 | 1];
	sand[x] = sand[x << 1] & sand[x << 1 | 1];
}
inline void pushdown(int x){
	if(tag[x] != -1){
		sor[x << 1] = sand[x << 1] = tag[x << 1] = sor[x << 1 | 1] = sand[x << 1 | 1] = tag[x << 1 | 1] = tag[x];
		tag[x] = -1;
	}
}
inline void change(int x, int L, int R, int pos, int val){ // dan dian xiu gai
	if(L == R){
		sor[x] += val; sand[x] += val;
		return;
	}
	pushdown(x);
	int mid = L + R >> 1;
	if(pos <= mid) change(x << 1, L, mid, pos, val);
	else change(x << 1 | 1, mid + 1, R, pos, val);
	pushup(x);
}
inline void modify(int x, int L, int R, int l, int r, int val){ // qu jian fu zhi
	if(l <= L && R <= r){
		sor[x] = sand[x] = tag[x] = val;
		return;
	}
	int mid = L + R >> 1;
	pushdown(x);
	if(l <= mid) modify(x << 1, L, mid, l, r, val);
	if(mid < r) modify(x << 1 | 1, mid + 1, R, l, r, val);
	pushup(x);
}
inline int find0(int x, int L, int R, int pos){ // find0
	if(sand[x] == inf) return -1;
	if(L == R) return L;
	pushdown(x);
	int mid = L + R >> 1;
	if(pos <= mid){
		int tmp = find0(x << 1, L, mid, pos);
		if(tmp == -1) return find0(x << 1 | 1, mid + 1, R, pos);
		else return tmp;
	} else return find0(x << 1 | 1, mid + 1, R, pos);
}
inline int find1(int x, int L, int R, int pos){ // find1
	if(sor[x] == 0) return -1;
	if(L == R) return L;
	pushdown(x);
	int mid = L + R >> 1;
	if(pos <= mid){
		int tmp = find1(x << 1, L, mid, pos);
		if(tmp == -1) return find1(x << 1 | 1, mid + 1, R, pos);
		else return tmp;
	} else return find1(x << 1 | 1, mid + 1, R, pos);
}
inline int query(int x, int L, int R, int pos){ // dan dian cha xun
	if(L == R) return sor[x];
	int mid = L + R >> 1;
	pushdown(x);
	if(pos <= mid) return query(x << 1, L, mid, pos);
	else return query(x << 1 | 1, mid + 1, R, pos);
}
inline void add(int pos, int val){
	if(!val) return;
	int tmp = query(1, 0, len, pos);
//	printf("tmp = %d\n", tmp);
	if(tmp + val <= inf){change(1, 0, len, pos, val); return;}
	else {
		change(1, 0, len, pos, val - inf - 1);
		int p = find0(1, 0, len, pos + 1);
		if(p != pos + 1) modify(1, 0, len, pos + 1, p - 1, 0);
		change(1, 0, len, p, 1);
	}
}
inline void del(int pos, int val){
	if(!val) return;
	int tmp = query(1, 0, len, pos);
//	printf("tmp = %d\n", tmp);
	if(tmp - val >= 0){change(1, 0, len, pos, -val); return;}
	else {
		change(1, 0, len, pos, inf + 1 - val);
		int p = find1(1, 0, len, pos + 1);
		if(p != pos + 1) modify(1, 0, len, pos + 1, p - 1, inf);
		change(1, 0, len, p, -1);
	}
}
int n, t1, t2, t3, opt, a, b;
int main(){
	scanf("%d%d%d%d", &n, &t1, &t2, &t3);
	memset(tag, -1, sizeof tag);
	while(n --){
		scanf("%d%d", &opt, &a);
		if(opt == 1){
			scanf("%d", &b);
			int pos = b / 30;
			if(a > 0){
				add(pos, (a << (b - pos * 30)) & inf);
				add(pos + 1, a >> ((pos + 1) * 30 - b));
			} else {
				a = -a;
				del(pos, (a << (b - pos * 30)) & inf);
				del(pos + 1, a >> ((pos + 1) * 30 - b));
			}
		} else {
			int pos = a / 30;
			putchar((query(1, 0, len, pos) & (1 << (a - pos * 30))) ? '1' : '0');
			putchar('\n');
		}
	}
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.321 ms15 MB + 396 KBAcceptedScore: 4

Testcase #21.357 ms15 MB + 396 KBAcceptedScore: 4

Testcase #31.894 ms15 MB + 396 KBAcceptedScore: 4

Testcase #42.059 ms15 MB + 400 KBAcceptedScore: 4

Testcase #54.765 ms15 MB + 404 KBAcceptedScore: 4

Testcase #63.432 ms15 MB + 408 KBAcceptedScore: 4

Testcase #76.954 ms15 MB + 564 KBAcceptedScore: 4

Testcase #86.587 ms15 MB + 408 KBAcceptedScore: 4

Testcase #920.692 ms15 MB + 920 KBAcceptedScore: 4

Testcase #1036.282 ms16 MB + 244 KBAcceptedScore: 4

Testcase #1135.219 ms15 MB + 472 KBAcceptedScore: 4

Testcase #1223.961 ms16 MB + 492 KBAcceptedScore: 4

Testcase #1348.128 ms16 MB + 580 KBAcceptedScore: 4

Testcase #14143.374 ms18 MB + 744 KBAcceptedScore: 4

Testcase #15116.917 ms20 MB + 392 KBAcceptedScore: 4

Testcase #16297.633 ms22 MB + 40 KBAcceptedScore: 4

Testcase #17316.576 ms15 MB + 980 KBAcceptedScore: 4

Testcase #18464.842 ms25 MB + 360 KBAcceptedScore: 4

Testcase #19555.266 ms27 MB + 4 KBAcceptedScore: 4

Testcase #20297.623 ms28 MB + 976 KBAcceptedScore: 4

Testcase #21392.157 ms30 MB + 312 KBAcceptedScore: 4

Testcase #22598.252 ms16 MB + 444 KBAcceptedScore: 4

Testcase #23790.559 ms31 MB + 184 KBAcceptedScore: 4

Testcase #24626.081 ms16 MB + 520 KBAcceptedScore: 4

Testcase #25812.491 ms31 MB + 900 KBAcceptedScore: 4


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