BZOJ3715: [PA2014]Lustra

3715: [PA2014]Lustra

Time Limit: 10 Sec  Memory Limit: 128 MB
Submit: 237  Solved: 149
[Submit][Status]

Description

Byteasar公司专门外包生产带有镜子的衣柜。
刚刚举行的招标会上,有n个工厂参加竞标。所有镜子都是长方形的,每个工厂能够制造的镜子都有其各自的最大、最小宽度和最大、最小高度。镜子不可以旋转。
如果存在某家工厂满足这样的条件:其他所有工厂能够制造的镜子,它都能够制造。那么这家工厂显然会胜出。若不存在,评判工作将会遇到麻烦。Byteasar想知道,是否存在某家工厂符合上述条件。

Input

第一行有一个整数t(1<=t<=10),表示测试数据数量。
对于每一组测试数据,第一行有一个整数n(2<=n<=100000)。接下来n行,每行有四个整数w1,w2,h1,h2(1<=w1<=w2<=10^9,1<=h1<=h2<=10^9),表示这家工厂能够制造的镜子的宽度w、高度h需要满足w1<=w<=w2,h1<=h<=h2。

Output

输出共有t行,每行为TAK(是)或NIE(否),表示是否存在某家工厂符合条件。

Sample Input

3
3
2 3 3 5
1 4 2 6
1 3 4 6
3
1 5 1 3
2 4 1 3
3 4 2 5
4
1 2 1 10
1 2 3 8
2 2 7 10
1 2 1 10

Sample Output

TAK
NIE
TAK

HINT

 

Source

题解:
果真在逗我!最小取最小,最大取最大,然后判断有没有一个工厂4个都是极值
代码:
 1 #include<cstdio>
 2 #include<cstdlib>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<iostream>
 7 #include<vector>
 8 #include<map>
 9 #include<set>
10 #include<queue>
11 #include<string>
12 #define inf 1000000000
13 #define maxn 100000+5
14 #define maxm 500+100
15 #define eps 1e-10
16 #define ll long long
17 #define pa pair<int,int>
18 #define for0(i,n) for(int i=0;i<=(n);i++)
19 #define for1(i,n) for(int i=1;i<=(n);i++)
20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
22 #define mod 1000000007
23 using namespace std;
24 inline int read()
25 {
26     int x=0,f=1;char ch=getchar();
27     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
28     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
29     return x*f;
30 }
31 int n,a[maxn],b[maxn],c[maxn],d[maxn],aa,bb,cc,dd;
32 bool jud()
33 {
34     for1(i,n)if(a[i]==aa&&b[i]==bb&&c[i]==cc&&d[i]==dd)return 1;
35     return 0;
36 }
37 int main()
38 {
39     freopen("input.txt","r",stdin);
40     freopen("output.txt","w",stdout);
41     int cs=read();
42     while(cs--)
43     {
44         n=read();
45         for1(i,n)a[i]=read(),b[i]=read(),c[i]=read(),d[i]=read();
46         aa=*min_element(a+1,a+n+1);
47         bb=*max_element(b+1,b+n+1);
48         cc=*min_element(c+1,c+n+1);
49         dd=*max_element(d+1,d+n+1);
50         if(jud())printf("TAK
");else printf("NIE
");
51     }
52     return 0;
53 }
View Code
原文地址:https://www.cnblogs.com/zyfzyf/p/4100963.html