Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:这神题(像LS所说)只有写错了才能A。。。。。。无语 一整天搭进去了

Posted by 1106100214 at 2012-07-23 06:49:12 on Problem 2528
In Reply To:Re:这神题(像LS所说)只有写错了才能A。。。。。。无语 一整天搭进去了 Posted by:Gzs_iceberg at 2012-06-16 02:13:05
#include <cstdio>
#include <cstring>
struct LT {
	int linestart,lineend;
	bool notcovered;
	LT *left,*right;
	~LT() {delete left;delete right;}
};
typedef LT *line;
line build(int l,int r) {
	line root = new LT;
	root->linestart = l;
	root->lineend = r;
	root->notcovered = true;
	if (~(l-r)) {
		root->left = build(l,(r+l)/2);
		root->right = build((r+l)/2,r);
	} else {
		root->left = root->right = NULL;
	}
	return root;
}
bool post(line t,int l,int r) {
	bool returnbl;
	if (r <= t->linestart || l >= t->lineend) return false;
	if (l <= t->linestart && r >= t->lineend) {
		returnbl = t->notcovered;
		t->notcovered = false;
		return returnbl;
	}
	if (t->notcovered) {
		returnbl = post(t->left,l,r);
		if (post(t->right,l,r)) returnbl = true;
		t->notcovered = (t->left->notcovered || t->right->notcovered);
		return returnbl;
	}
	return false;
}

struct pst {
	int start,end;
}poster[10005];

int dismaping[10000005];

int main() {
	int c,n,i,count;
	line wall;
	scanf("%d",&c);
	while (c--) {
		scanf("%d",&n);
		memset(dismaping,0,sizeof(dismaping));
		i = n;
		while (i--) {
			scanf("%d%d",&poster[i].start,&poster[i].end);
			dismaping[poster[i].start-1] = dismaping[poster[i].end] = 2;//=1才能Ac
		}
		for (i = 1; i < 10000005; i++) {
			dismaping[i] += dismaping[i-1];
		}
		wall = build(0,dismaping[10000001]);
		count = 0;
		for (i = 0; i < n; i++) {
			if (post(wall,dismaping[poster[i].start]-1,dismaping[poster[i].end])) ++count;
		}
		printf("%d\n",count);
	}
	return 0;
}
看我的代码吧,楼上这样说可真错了,我的离散化自认为好点,那个动态申请的线段树大家忽略掉把Xd

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator