Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
和暴力对拍时惊出一身冷汗……这题离散化太恶心了…… 见代码: 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator