题目连接:http://acm.tju.edu.cn/toj/showp2392.html2392.   Box


Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 846   Accepted Runs: 304    Multiple test files

Ivan works at a factory that produces heavy machinery. He has a simple job — he knocks up wooden boxes of different sizes to pack machinery for delivery to the customers. Each box is a rectangular parallelepiped. Ivan uses six rectangular wooden pallets to make a box. Each pallet is used for one side of the box.

Joe delivers pallets for Ivan. Joe is not very smart and often makes mistakes — he brings Ivan pallets that do not fit together to make a box. But Joe does not trust Ivan. It always takes a lot of time to explain Joe that he has made a mistake.

Fortunately, Joe adores everything related to computers and sincerely believes that computers never make mistakes. Ivan has decided to use this for his own advantage. Ivan asks you to write a program that given sizes of six rectangular pallets tells whether it is possible to make a box out of them.

Input

Input consists of six lines. Each line describes one pallet and contains two integer numbers w and h (1 ≤ wh ≤ 10 000) — width and height of the pallet in millimeters respectively.

Output

Write a single word "POSSIBLE" to the output if it is possible to make a box using six given pallets for its sides. Write a single word "IMPOSSIBLE" if it is not possible to do so.

Sample Input Sample Output
1345 2584
2584 683
2584 1345
683 1345
683 1345
2584 683
POSSIBLE
1234 4567
1234 4567
4567 4321
4322 4567
4321 1234
4321 1234
IMPOSSIBLE

Source: Northeastern European 2004

题解: :对面进行排序,比较相邻的两个面是否相同,当两个面相同的时候看第一个面和第三个面是否有公共边,最后看最后的面可以和前两个面连起来吗

重复的东西可以写成函数 不易出错,

这里注意,如果最后满足题意的有一种情况的时候,flag定义成false,有一个满足就更新成true,

而要找所有条件都满足的时候,开始将flag定义成true,有一个不满足就更新成false

其实刷水题还是有用的,gaga.

 #include <cstdio>
#include <algorithm>
using namespace std; struct pg{
int x, y;
bool operator < (const pg a) const {
return x == a.x ? y < a.y : x < a.x;
}
}p[];
bool ch(int x, int y, pg tm)
{
if(x > y) swap(x, y);
return x == tm.x && y == tm.y;
} int main()
{
while(~scanf("%d %d", &p[].x, &p[].y))
{
for(int i = ; i < ; i++) scanf("%d %d", &p[i].x, &p[i].y);
for(int i = ; i < ; i++) if(p[i].x > p[i].y) swap(p[i].x, p[i].y);
sort(p, p+);
if(p[].x != p[].x || p[].y != p[].y || p[].x != p[].x || p[].y != p[].y || p[].x != p[].x || p[].y != p[].y)
{
puts("IMPOSSIBLE");
continue;
}
pg a = p[], b = p[], c = p[];
int t1, t2;
bool flag = false;
if(a.x == b.x && ch(a.y, b.y, c)) flag = true;
if(a.x == b.y && ch(a.y, b.x, c)) flag = true;
if(a.y == b.x && ch(a.x, b.y, c)) flag = true;
if(a.y == b.y && ch(a.x, b.x, c)) flag = true;
if(flag) puts("POSSIBLE");
else puts("IMPOSSIBLE");
}
return ;
}

BOX的更多相关文章

  1. Virtual Box配置CentOS7网络(图文教程)

    之前很多次安装CentOS7虚拟机,每次配置网络在网上找教程,今天总结一下,全图文配置,方便以后查看. Virtual Box可选的网络接入方式包括: NAT 网络地址转换模式(NAT,Network ...

  2. Linux监控工具介绍系列——OSWatcher Black Box

      OSWatcher Balck Box简介 OSWatcher Black Box (oswbb)是Oracle开发.提供的一个小巧,但是实用.强大的系统工具,它可以用来抓取操作系统的性能指标,用 ...

  3. 使用packer制作vagrant centos box

    使用packer制作vagrant box:centos 制作vagrant box,网上有教程,可以自己step by step的操作.不过直接使用虚拟在VirtualBox中制作vagrant b ...

  4. 快速打造跨平台开发环境 vagrant + virtualbox + box

    工欲善其事必先利其器,开发环境 和 开发工具 就是 我们开发人员的剑,所以我们需要一个快并且好用的剑 刚开始做开发的时候的都是把开发环境 配置在 自己的电脑上,随着后面我们接触的东西越来越多,慢慢的电 ...

  5. CSS3伸缩盒Flexible Box

    这是一种全新的布局,在移动端非常实用,IE对此布局的相关的兼容不是很好,Firefox.Chrome.Safrai等需要加浏览器前缀. 先说说这种布局的特点: 1)移动端由于屏幕宽度都不一样,在布局的 ...

  6. CSS3与页面布局学习总结(二)——Box Model、边距折叠、内联与块标签、CSSReset

    一.盒子模型(Box Model) 盒子模型也有人称为框模型,HTML中的多数元素都会在浏览器中生成一个矩形的区域,每个区域包含四个组成部分,从外向内依次是:外边距(Margin).边框(Border ...

  7. 解析opencv中Box Filter的实现并提出进一步加速的方案(源码共享)。

    说明:本文所有算法的涉及到的优化均指在PC上进行的,对于其他构架是否合适未知,请自行试验. Box Filter,最经典的一种领域操作,在无数的场合中都有着广泛的应用,作为一个很基础的函数,其性能的好 ...

  8. HDOJ 1326. Box of Bricks 纯水题

    Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  9. 一个简单的CSS3+js 实现3D BOX

    <!doctype html><html><head> <meta charset="UTF-8"> <title>Do ...

  10. Appcan——Box

    Box架构 ub….. Box架构元素空间大小分配比例 ub-f……. Ub-f1,ub-f2,ub-f3……. Box架构元素垂直方向的位置排列 ub-ac,ub-ae… -webkit-box-a ...

随机推荐

  1. jsp程序设计:jstl之JSTL标签库

    转载自:http://www.blogjava.net/haizhige/archive/2008/10/26/236783.html,个人进行了一些修改. 前言:写一个taglib一般可以继承Sim ...

  2. Ubuntu上安装flashplayer

    当你已经为linux flashplayer无法安装抓狂的时候,不妨来看看吧 我使用的是Ubuntu 12.04.4 LTS,由于firefox无法播放flash所以去下载了一个adobeflashp ...

  3. Docker(七):Docker容器卷管理

    1.使用容器卷的原因:Docker容器产生的数据,如果不通过commit生成新的镜像,数据会在容器删除后丢失.为了能持久化保存和共享容器的数据,Docker提出了两种管理数据的方式:数据卷和数据卷容器 ...

  4. cleanMyMac

    想看外国网站可以找我,facebook.youtube.XX大片等,只要8元钱,无限制用到服务器关闭.看大片流畅不成问题 需要cleanMyMac的请加微信只要10或直接拍 http://a.p6ff ...

  5. shiro Filter--拦截器

    一 shiro自带的filter:下面主要叙述顺序是 NameableFilter->OncePerRequestFilter->AdviceFilter->PathMatching ...

  6. python利用pysvn发布lib的小程序

    背景: 本人在公司的平台部门工作,我们部门写出的代码都是编译成.a文件,定期发布版本到各个产品,现在老大要求我负责每周向公司的某个产品发布lib.发布lib的步骤大概就是自动化的兄弟给我提供一个归档的 ...

  7. MVC框架实例构建

    转自:http://www.cnblogs.com/levenyes/p/3290885.html MVC全名是Model View Controller,是模型(model)-视图(view)-控制 ...

  8. 在Ubuntu14.04上搭建自己的OpenVPN服务器并通过它上网

    背景 学校宿舍端口可以配置静态IP连校内网,也可以连到实验室的服务器:实验室的服务器可以连外网:但宿舍要连外网就要花钱买PPPoE账号了.作为壮哉我大计院的一员,本着发扬专(neng)业(sheng) ...

  9. Java学习笔记19---内部类之简介成员内部类、局部内部类及匿名内部类

    内部类,顾名思义,即定义在某个类内部的类,称包含该内部类的类为外部类. 从定义的位置来说,分为成员内部类和局部内部类:从类的特征来说,分为匿名内部类和静态内部类. 今天先简要介绍一下前三种内部类的定义 ...

  10. keepalived(nat)+ftp+http

    一. 环境要求需要2台LVS和n(n>=2)台RS操作系统 负载均衡模式 VIP NVIPRHEL7.4 NAT 193.168.141.30 192.168.102.165 LVS1 LVS2 ...