codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

993A.md (1878B)


      1 Source: https://codeforces.com/problemset/problem/993/A
      2 
      3 A. Two Squares
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.
     22 
     23 The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the two squares only share one common point, they are also considered to intersect.
     24 
     25 Input
     26 
     27 The input data consists of two lines, one for each square, both containing 4 pairs of integers. Each pair represents coordinates of one vertex of the square. Coordinates within each line are either in clockwise or counterclockwise order.
     28 
     29 The first line contains the coordinates of the square with sides parallel to the coordinate axes, the second line contains the coordinates of the square at 45 degrees.
     30 
     31 All the values are integer and between $-100$ and $100$.
     32 
     33 Output
     34 
     35 Print "Yes" if squares intersect, otherwise print "No".
     36 
     37 You can print each letter in any case (upper or lower).
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 0 0 6 0 6 6 0 6  
     45 1 3 3 5 5 3 3 1
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 YES
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 0 0 6 0 6 6 0 6  
     58 7 3 9 5 11 3 9 1
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 NO
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 6 0 6 6 0 6 0 0  
     71 7 4 4 7 7 10 10 7
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 YES
     78 ```
     79 
     80 Note
     81 
     82 In the first example the second square lies entirely within the first square, so they do intersect.
     83 
     84 In the second sample squares do not have any points in common.
     85 
     86 Here are images corresponding to the samples:
     87 
     88  ![](https://espresso.codeforces.com/73ea9d4dacf49c0c31bbb1cb457bba6c0b1e5f57.png)  ![](https://espresso.codeforces.com/2298f1d19747a4151e08ae09e7102c905c149edc.png)  ![](https://espresso.codeforces.com/d8ae723351e525099008fa1d205ae694ba9d6974.png)