Trace2018徐州icpc网络赛思维+二分 | 您所在的位置:网站首页 › icpc中国赛区 › Trace2018徐州icpc网络赛思维+二分 |
There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy) means the wave is a rectangle whose vertexes are ( 00 , 00 ), ( xx , 00 ), ( 00 , yy ), ( xx , yy ). Every time the wave will wash out the trace of former wave in its range and remain its own trace of ( xx , 00 ) -> ( xx , yy ) and ( 00 , yy ) -> ( xx , yy ). Now the toad on the coast wants to know the total length of trace on the coast after n waves. It's guaranteed that a wave will not cover the other completely. InputThe first line is the number of waves n(n \le 50000)n(n≤50000). The next nn lines,each contains two numbers xxyy ,( 0 0x , y \le 10000000y≤10000000 ),the ii-th line means the ii-th second there comes a wave of ( xx , yy ), it's guaranteed that when 1 \le i1≤i , j \le nj≤n,x_i \le x_jxi≤xj and y_i \le y_jyi≤yj don't set up at the same time. OutputAn Integer stands for the answer. Hint:As for the sample input, the answer is 3+3+1+1+1+1=103+3+1+1+1+1=10 |
CopyRight 2018-2019 实验室设备网 版权所有 |