| Task: | Line Segment Intersection |
| Sender: | aalto26jh_032 |
| Submission time: | 2026-11-11 16:12:23 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.09 s | details |
| #2 | WRONG ANSWER | 0.10 s | details |
| #3 | WRONG ANSWER | 0.12 s | details |
| #4 | WRONG ANSWER | 0.13 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp: In member function 'bool point::operator==(const point&) const':
input/code.cpp:25:17: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
25 | return x==b.x &y==b.y;
| ~^~~~~
input/code.cpp: In member function 'bool line::intersect(line&)':
input/code.cpp:32:15: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
32 | if ( a==o.a|a==o.b|b==o.a|b==o.b) return true;
| ~^~~~~
input/code.cpp:32:29: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
32 | if ( a==o.a|a==o.b|b==o.a|b==o.b) return true;
| ~^~~~~
input/code.cpp:32:36: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
32 | if ( a==o.a|a==o.b|b==o.a|b==o.b) return true;
| ~^~~~~
input/code.cpp:40:19: warning: suggest parentheses around compar...Code
#include <array>
#include <iostream>
#include <vector>
#include <climits>
#include <cstdint>
using namespace std;
#define DEBUG std::cout<<"LINE"<<__LINE__;
#define IN(A) int A;std::cin>>A;
template<typename T> void printV(vector<T> V) {
for (int i=0;i<V.size()-1;i++) {
cout<<V[i]<<" ";
}
cout<<V[V.size()-1];
cout<<endl;
}
int64_t max3(int64_t a,int64_t b,int64_t c) {
return max(a,max(b,c));
}
struct point {
int x,y;
bool operator==(const point &b) const {
return x==b.x &y==b.y;
}
};
struct line {
point a,b;
bool intersect(line &o ) {
if ( a==o.a|a==o.b|b==o.a|b==o.b) return true;
int64_t e,f=0;
int t1=min(a.x,b.x);
int t2=max(a.x,b.x);
int t3=min(o.a.x,o.b.x);
int t4=max(o.a.x,o.b.x);
if ((*this)*o==0) {
if (t1<=t3&t2>=t3) return true;
if (t3<=t1&t4>=t1) return true;
}
auto ta=o*a;
auto tb=o*b;
auto oa= *this*o.a;
auto ob=*this*o.b;
if ((ta<=0&tb>=0)||(ta>=0&tb<=0)&&(oa<=0&ob>=0)||(oa>=0&ob<=0)) return true;
return false;
}
__inline int64_t operator*(const line &o) {
return (a.x-b.x)*(o.a.y-o.b.y)-(o.a.x-o.b.x)*(a.y-b.y);
}
__inline int64_t operator*(const point &o) {
return (o.x-a.x)*(o.y-b.y)-(o.y-a.y)*(o.x-b.x);
}
};
struct compute {
int tests=1;
vector<array<line,2>> data;
vector<pair<int,int>> result;
vector<bool> visited;
bool start() {
IN(n);
data.assign(n,{});
for (int j=0;j<n;j++) {
for (int i=0;i<2;i++) {
cin>>data[j][i].a.x;
cin>>data[j][i].a.y;
cin>>data[j][i].b.x;
cin>>data[j][i].b.y;
}
}
for (auto &l:data ) {
if ( l[0].intersect(l[1]))
{ cout<< "YES\n";}
else cout<<"NO\n";
}
return true;
}
void readV(int n) {
//for (int i=0;i<n;i++) cin>>data[i];
}
void testloop(){
while (tests-->0) {
start();
}
}
};
int main() {
ios_base::sync_with_stdio(false);
// cin.tie(NULL);
compute comp;
comp.start();
}
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 |
|---|
| NO YES NO NO NO ... |
Feedback: Incorrect character on line 2 col 1: expected "NO", got "YES"
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 100000 81 745 -967 768 -451 -490 -454... |
| correct output |
|---|
| NO NO YES NO YES ... |
| user output |
|---|
| YES YES YES NO YES ... |
Feedback: Incorrect character on line 1 col 1: expected "NO", got "YES"
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 100000 492853 -452834 -657156 -282543... |
| correct output |
|---|
| YES YES NO YES YES ... |
| user output |
|---|
| NO YES NO NO NO ... |
Feedback: Incorrect character on line 1 col 1: expected "YES", got "NO"
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 100000 788522666 939776556 -831492125... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| YES YES NO NO NO ... |
Feedback: Incorrect character on line 1 col 1: expected "NO", got "YES"
Test 5
Verdict: ACCEPTED
| input |
|---|
| 1 1 6 6 6 4 4 1000000000 1000000... |
| correct output |
|---|
| YES |
| user output |
|---|
| YES |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 1 -1000000000 1000000000 9999999... |
| correct output |
|---|
| NO |
| user output |
|---|
| NO |
