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

和暴力对拍时惊出一身冷汗……

Posted by Ever_ljq at 2011-06-09 20:41:01 on Problem 2528
这题离散化太恶心了……
见代码:
void init()
{
	scanf("%d", &n); ns = 0;
	for (int i = 1; i <= n; i++){
		scanf("%d%d", &Ls[i], &rs[i]);
		num[++ns] = Ls[i]; num[++ns] = rs[i];
	}
	quick_sort(1, ns); ns1 = ns; ns = 0; num1[0] = -1;
	for (int i = 1; i <= ns1; i++) num1[i] = num[i];
	for (int i = 1; i <= ns1; i++)
		if (num1[i] != num1[i-1]){
			if (num1[i] > num1[i-1] + 1) num[++ns] = num1[i-1] + 1;
			num[++ns] = num1[i];		
		}
	for (int i = 1; i <= n; i++){
		Ls[i] = find(Ls[i]);
		rs[i] = find(rs[i]); 
	}
	build_tree(1, 1, ns);
}
一次AC.

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