Segment, segmentation

Source: Internet
Author: User

Segment, segmentation

Description

GivenNSegments in the two dimen1_space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected segments have at least one point in common.

Input

Input begins with a numberTShowing the number of test cases and then,TTest cases follow. Each test case begins with a line containing a positive integerN≤0. 100 showing the number of segments. After that,NLines containing four real numbersX1Y1X2Y2 follow, in which (X1,Y1) and (X2,Y2) are the coordinates of the two endpoints for one of the segments.

Output

For each test case, your program must output "Yes! ", If a line with desired property exists and must output" No! "Otherwise. You must assume that two floating point numbersAAndBAre equal if |A-B| <10-8.

Sample Input

321.0 2.0 3.0 4.04.0 5.0 6.0 7.030.0 0.0 0.0 1.00.0 1.0 0.0 2.01.0 1.0 2.0 1.030.0 0.0 0.0 1.00.0 2.0 0.0 3.01.0 1.0 2.0 1.0

Sample Output

Yes!Yes!No!
 
# Include <iostream> # include <cmath> # include <cstdio> using namespace std; # define EPS 1e-8int n; struct Segment {double x1, x2, y1, y2 ;} segment [1000]; double distance (double x1, double y1, double x2, double y2) {return sqrt (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2);} double fun (double x1, double y1, double x2, double y2, double x0, double y0) {return (x2-x1) * (y0-y1) -(x0-x1) * (y2-y1);} bool search (double x1, double y1, doub Le x2, double y2) {int I; // determines whether the same line is used. if (distance (x1, y1, x2, y2) <EPS) return false; // use the Cross Product Theorem to determine if it is intersecting with other line segments: for (I = 0; I <n; I ++) {if (fun (x1, y1, x2, y2, segment [I]. x1, segment [I]. y1) * fun (x1, y1, x2, y2, segment [I]. x2, segment [I]. y2)> EPS) return false;} return true;} int main () {// freopen ("a.txt", "r", stdin); int t; scanf ("% d", & t); while (t --) {scanf ("% d", & n); int I; for (I = 0; I <n; I ++) scanf ("% lf", & segme Nt [I]. x1, & segment [I]. y1, & segment [I]. x2, & segment [I]. y2); if (n = 1) {printf ("Yes! \ N "); continue;} int ans = 0; // list all line segments; for (I = 0; I <n; I ++) for (int j = I + 1; j <n; j ++) {if (search (segment [I]. x1, segment [I]. y1, segment [j]. x1, segment [j]. y1) | search (segment [I]. x1, segment [I]. y1, segment [j]. x2, segment [j]. y2) | search (segment [I]. x2, segment [I]. y2, segment [j]. x1, segment [j]. y1) | search (segment [I]. x2, segment [I]. y2, segment [j]. x2, segment [j]. y2) ans = 1;} if (ans) printf ("Yes! \ N "); else printf (" No! \ N ") ;}return 0 ;}



After the computer restarts, file record segment appears ......

This is a normal system recovery process for your Windows behavior.

Your two images show that the file system of the E disk is suspected to be damaged, and the system is recovering the file system. This is a system self-check and self-protection. As for the reason, it is caused by your abnormal shutdown. The system does not exit normally and the mark of the last normal shutdown is not detected during startup. Therefore, it is suspected that your file is damaged, self-check is an error recovery action;

This process does not occur if the file system is shut down normally after the self-check is resumed. If an abnormal shutdown occurs, the system may perform self-check on the disk file system at the next boot.
It is recommended that the system be shut down normally and exited. An abnormal shutdown may cause damage to hardware, especially hard disks.

After the computer restarts, file record segment appears ......

This is a normal system recovery process for your Windows behavior.

Your two images show that the file system of the E disk is suspected to be damaged, and the system is recovering the file system. This is a system self-check and self-protection. As for the reason, it is caused by your abnormal shutdown. The system does not exit normally and the mark of the last normal shutdown is not detected during startup. Therefore, it is suspected that your file is damaged, self-check is an error recovery action;

This process does not occur if the file system is shut down normally after the self-check is resumed. If an abnormal shutdown occurs, the system may perform self-check on the disk file system at the next boot.
It is recommended that the system be shut down normally and exited. An abnormal shutdown may cause damage to hardware, especially hard disks.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.