Skip to content

Commit 2ae1800

Browse files
authored
Merge pull request ashutosh97#143 from ShivamMangale/master
Added White-Sheet
2 parents e516936 + 2cc9056 commit 2ae1800

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

White-Sheet/White-Sheet.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates (0,0), and coordinate axes are left and bottom sides of the table, then the bottom left corner of the white sheet has coordinates (x1,y1), and the top right — (x2,y2).
2+
After that two black sheets of paper are placed on the table. Sides of both black sheets are also parallel to the sides of the table. Coordinates of the bottom left corner of the first black sheet are (x3,y3), and the top right — (x4,y4). Coordinates of the bottom left corner of the second black sheet are (x5,y5), and the top right — (x6,y6).
3+
4+
5+
Determine if some part of the white sheet can be seen from the above after the two black sheets are placed. The part of the white sheet can be seen if there is at least one point lying not strictly inside the white sheet and strictly outside of both black sheets.
6+
Input
7+
The first line of the input contains four integers x1,y1,x2,y2 (0≤x1<x2≤106,0≤y1<y2≤106) — coordinates of the bottom left and the top right corners of the white sheet.
8+
The second line of the input contains four integers (0≤x3<x4≤106,0≤y3<y4≤106) — coordinates of the bottom left and the top right corners of the first black sheet.
9+
The third line of the input contains four integers (0≤x5<x6≤106,0≤y5<y6≤106) — coordinates of the bottom left and the top right corners of the second black sheet.
10+
The sides of each sheet of paper are parallel (perpendicular) to the coordinate axes.
11+
Output
12+
If some part of the white sheet can be seen from the above after the two black sheets are placed, print "YES" (without quotes). Otherwise print "NO".
13+
input
14+
2 2 4 4
15+
1 1 3 5
16+
3 1 5 5
17+
18+
19+
Output
20+
NO
21+
22+
23+
input
24+
3 3 7 5
25+
0 0 4 6
26+
0 0 7 4
27+
28+
29+
output
30+
YES
31+
32+
33+
input
34+
35+
36+
5 2 10 5
37+
3 1 7 6
38+
8 1 11 7
39+
40+
41+
output
42+
YES
43+
44+
45+
input
46+
47+
48+
0 0 1000000 1000000
49+
0 0 499999 1000000
50+
500000 0 1000000 1000000
51+
52+
53+
output
54+
YES

White-Sheet/code.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//https://codeforces.com/contest/1216/problem/C
2+
//587-Div 3-C
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
typedef long long int ll;
7+
8+
9+
int main()
10+
{
11+
ios::sync_with_stdio(false);
12+
cin.tie(0);
13+
cout.tie(0);
14+
15+
ll x11,x12,y11,y12;
16+
ll x21,x22,y21,y22;
17+
ll x31,x32,y31,y32;
18+
19+
ll area = 0;
20+
21+
cin>>x11>>y11>>x12>>y12;
22+
cin>>x21>>y21>>x22>>y22;
23+
cin>>x31>>y31>>x32>>y32;
24+
25+
area = abs(x11-x12)*abs(y11-y12);
26+
x21 = max(x11,x21);
27+
y21 = max(y11,y21);
28+
x22 = min(x12,x22);
29+
y22 = min(y12,y22);
30+
x31 = max(x11,x31);
31+
y31 = max(y11,y31);
32+
x32 = min(x12,x32);
33+
y32 = min(y12,y32);
34+
ll a1,a2,b1,b2;
35+
if(x21 < x22 && y21 < y22) area -= abs(x21-x22)*abs(y21-y22);
36+
if(x31 < x32 && y31 < y32) area -= abs(x31-x32)*abs(y31-y32);
37+
if((x21<x31 && x22>x31) || (x21<x32 && x22>x32))
38+
{
39+
if((y21 < y31 && y22 > y31) || (y21 < y32 && y22 > y32))
40+
{
41+
ll narea = 0;
42+
43+
}
44+
}
45+
46+
a1 = max(x21,x31);
47+
b1 = max(y21,y31);
48+
a2 = min(x22,x32);
49+
b2 = min(y22,y32);
50+
51+
if(a1 < a2 && b1 < b2) area += abs(a2-a1)*abs(b2-b1);
52+
53+
if(area > 0) cout<<"YES\n";
54+
else cout<<"NO\n";
55+
56+
return 0;
57+
}

0 commit comments

Comments
 (0)