| ||||||||||
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 |
为什么用黑书的判断相交方法不能过,用discuss里面的可以?判断相交的函数:(黑书的模板,WA) int segCross(Segment a, Segment b) { int c1 = getCross(a.a, a.b, b.a); int c2 = getCross(a.a, a.b, b.b); int c3 = getCross(b.a, b.b, a.a); int c4 = getCross(b.a, b.b, a.b); if ((c1 ^ c2) == -2 && (c3 ^ c4) == -2) { return 1; } if (c1 == 0 && getDot(b.a, a.a, a.b) <= 0) { return 2; } if (c2 == 0 && getDot(b.b, a.a, a.b) <= 0) { return 2; } if (c3 == 0 && getDot(a.a, b.a, b.b) <= 0) { return 2; } if (c4 == 0 && getDot(a.b, b.a, b.b) <= 0) { return 2; } return 0; } 用discuss里面有人的代码可以过: bool isCross(Segment a, Segment b) { if (getCross(a.a, b.a, b.b) * getCross(a.b, b.a, b.b) <= 0) { return true; } else { return false; } } 其余的函数是一样的。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator