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(否),表示是否存在某家工厂符合条件。

题解:

长度,宽度分别模拟判断好了。

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
//by zrt
//problem:
using namespace std;
struct N{
    int w1,w2,h1,h2;
}a[],b[];
int tot;
int main(){
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t,n;
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        tot=;
        ;
        int maxpos;
        ;i<n;i++){
            scanf("%d%d%d%d",&a[i].w1,&a[i].w2,&a[i].h1,&a[i].h2);
            if(a[i].w2-a[i].w1>maxw){
                maxw=a[i].w2-a[i].w1;
                maxpos=i;
            }
        }
        ;
        ;i<n;i++){
            if(a[i].w1>=a[maxpos].w1&&a[i].w2<=a[maxpos].w2){
                ;
            }else{
                ok=;break;
            }
        }
        if(!ok){
            puts("NIE");continue;
        }
        ;i<n;i++){
            if(a[i].w1==a[maxpos].w1&&a[i].w2==a[maxpos].w2) b[tot++]=a[i];
        }
        maxw=-;
        ;i<tot;i++){
            if(b[i].h2-b[i].h1>maxw){
                maxw=b[i].h2-b[i].h1;
                maxpos=i;
            }
        }
        ;i<n;i++){
            if(a[i].h1>=b[maxpos].h1&&a[i].h2<=b[maxpos].h2){
                ;
            }else{
                ok=;break;
            }
        }
        if(!ok){
            puts("NIE");continue;
        }
        puts("TAK");
    }

    ;
}

BZOJ 3715: [PA2014]Lustra的更多相关文章

  1. BZOJ3715: [PA2014]Lustra

    3715: [PA2014]Lustra Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 237  Solved: 149[Submit][Status ...

  2. bzoj3715: [PA2014]Lustra(乱搞)

    3715: [PA2014]Lustra 题目:传送门 题解: 随手一发水题x1 随便排序一下...小学生题??? 代码: #include<cstdio> #include<cst ...

  3. [PA2014]Lustra

    [PA2014]Lustra 题目大意: 有n个工厂参加竞标.每个工厂能生产长度在\([a_i,b_i]\)之间,宽度在\([c_i,d_i]\)之间的镜子,镜子不可以旋转. 问是否有某个工厂能生产出 ...

  4. BZOJ 3721: PA2014 Final Bazarek

    3721: PA2014 Final Bazarek Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 645  Solved: 261[Submit][ ...

  5. BZOJ 3709: [PA2014]Bohater

    3709: [PA2014]Bohater Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 1050  Solved: ...

  6. 【贪心】bzoj 3709:[PA2014]Bohater

    3709: [PA2014]Bohater Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 653  Solved:  ...

  7. BZOJ 3713: [PA2014]Iloczyn( 枚举 )

    斐波那契数列<10^9的数很少很少...所以直接暴力枚举就行了... ------------------------------------------------------------- ...

  8. bzoj 3714 [PA2014]Kuglarz 最小生成树

    [PA2014]Kuglarz Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1335  Solved: 672[Submit][Status][Di ...

  9. bzoj 3722: PA2014 Final Budowa

    3722: PA2014 Final Budowa Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 303  Solved: 108[Submit][St ...

随机推荐

  1. 关于XML文档的讲解

    1        XML的概述 1.1 什么是XML XML全称为Extensible Markup Language,意思是可扩展的标记语言.XML语法上和HTML比较相似,但HTML中的元素是固定 ...

  2. 关于Eclipse中的快捷键占用的解决.

    刚进公司用的之前离职员工的电脑,打开Eclipse经常用的一个alt+/ 内容提示快捷键就是不好使. 让同事帮忙之后才发现原因. 在eclipse中快捷键设置是在  windows---->pr ...

  3. Java读取一个文件并打印到控制台上

    package test9; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundExcept ...

  4. MidPayinfoVO

    package nc.vo.arap.payablebill; import nc.vo.pub.SuperVO; import nc.vo.pub.lang.UFDate; import nc.vo ...

  5. h2database源码浅析:TransactionMap、MVMap、MVStore

    TransactionStore:A store that supports concurrent MVCC read-committed transactions. TransactionStore ...

  6. partial与sorted

    import functools sorted_ignore_case = functools.partial(sorted,cmp=lambda s1, s2: cmp(s1.upper(), s2 ...

  7. (四)JAVA使用POI操作excel

    1,字体处理 Demo12.java package com.wishwzp.poi; import java.io.FileOutputStream; import org.apache.poi.h ...

  8. 批处理 Mysql Findstr

    @set Dump_IP=localhost @set User_Name=root @set Password=1234 @set curPath=%~dp0 mysql -h %Dump_IP% ...

  9. Windows 键盘操作快捷方式积累

    复制.粘贴: CTRL+C 复制被选择的项目到剪贴板 CTRL+V 粘贴剪贴板中的内容到当前位置 CTRL+X 剪切被选择的项目到剪贴板 Alt+ space + E + P CMD 窗口快速粘贴 关 ...

  10. 让hyper-v调整console的大小

    在hyper-v中centos的console一直都是1024x768的分辨率,后来找到一种修改分辨率的解决方法 grubby --update-kernel=ALL --args="vid ...