Task: | Line Segment Intersection |
Sender: | Nallue |
Submission time: | 2024-11-12 11:13:52 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.30 s | details |
#2 | WRONG ANSWER | 0.35 s | details |
#3 | WRONG ANSWER | 0.44 s | details |
#4 | WRONG ANSWER | 0.52 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
Code
#include <iostream>#include <ccomplex>#include <vector>using namespace std;typedef long long C;typedef complex<C> P;#define X real()#define Y imag()#define cross(a,b) (conj(a)*b).Ybool intersection(P p1, P p2, P p3, P p4){if(p1 == p3 or p1 == p4 or p2 == p3 or p2 == p4)return 1;C c1 = cross(p3-p1,p3-p2);C c2 = cross(p4-p1,p4-p2);//cout << c1 << " " << c2 << endl;if((c1>=0 and c2<=0) or (c1<=0 and c2>=0))return true;return false;}int main(){int t;cin >> t;for(int i=0; i< t; i++){vector<P> vec(4);for(int l=0; l<4; l++){C a,b;cin >> a >> b;vec[l] = {a,b};}if(intersection(vec[0], vec[1], vec[2], vec[3])){cout << "YES" << endl;}else cout << "NO" << endl;}}
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
100000 9 7 1 8 8 -5 0 2 10 1 -1 2 -4 1 -7 3 10 2 -8 6 1 2 2 -1 -10 1 9 -7 4 -3 -5 0 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
YES NO YES YES NO ... Truncated |
Test 2
Verdict: WRONG ANSWER
input |
---|
100000 81 745 -967 768 -451 -490 -454... |
correct output |
---|
NO NO YES NO YES ... |
user output |
---|
NO NO NO NO YES ... Truncated |
Test 3
Verdict: WRONG ANSWER
input |
---|
100000 492853 -452834 -657156 -282543... |
correct output |
---|
YES YES NO YES YES ... |
user output |
---|
NO YES YES YES YES ... Truncated |
Test 4
Verdict: WRONG ANSWER
input |
---|
100000 788522666 939776556 -831492125... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
NO YES YES YES NO ... Truncated |
Test 5
Verdict: WRONG ANSWER
input |
---|
1 1 6 6 6 4 4 1000000000 1000000... |
correct output |
---|
YES |
user output |
---|
NO |
Test 6
Verdict: ACCEPTED
input |
---|
1 -1000000000 1000000000 9999999... |
correct output |
---|
NO |
user output |
---|
NO |