Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 476 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

Given the coordinates of the end points of **two line segments** and you have to check if they **intersect or not.**

**Input: **

The first line of input contains a single integer **T** denoting the number of test cases.Then **T** test cases follow. Each test case consists of **2** lines.The first line consists of **4** integers: **x _{1}, y_{1}, x_{2}, y_{2}** where (x

and (x

**Output:**

Corresponding to each test case, in a new line, print 1 if the line segments intersect, otherwise print 0.

**Constraints:**

1 ≤ T ≤ 300

-10^{6} ≤ x_{i},y_{i} ≤ 10^{6}

1 <= i** **<= 4

**Example:**

**Input:**

2

1 1 10 1

1 2 10 2

10 0 0 10

0 0 10 10

**Output:**

0

1

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Check If two Line segments Intersect

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.