题目连接: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. sftp新建用户步骤

    1,切换root用户2,创建sftp组:groupadd sftp3,创建用户并限制进入路径:useradd -g sftp -s /bin/false testuser 修改密码: passwd t ...

  2. Visual Studio Code 快捷键大全(Windows)

    Visual Studio Code 是一款优秀的编辑器,非常适合编写 TS 以及 React .最近在学习 AngularJs 2,开始使用 VSCode,特意整理翻译了一下官网的快捷键.因为已经习 ...

  3. NOI2009 植物大战僵尸

    啊一道好题感觉写得挺爽的啊这题这种有一点懵逼然后学了一点东西之后很明朗的感觉真是好!预处理参考 :http://www.cppblog.com/MatoNo1/archive/2014/11/01/1 ...

  4. PredictionIO+Universal Recommender快速开发部署推荐引擎的问题总结(2)

    1, 对Universal Recommender进行pio build成功,但是却提示No engine found Building and delpoying model [INFO] [Eng ...

  5. 浅析Node.js的Event Loop

    目录 浅析Node.js的Event Loop 引出问题 Node.js的基本架构 Libuv Event Loop Event Loop Phases Overview Poll Phase The ...

  6. 基于Java Mail 进行发送(带附件和压缩附件)的邮件

    刚进公司的training, 下面是要求: Self-study of Java Mail library:  http://www.oracle.com/technetwork/java/javam ...

  7. haslayout知多少

    我们都知道浏览器有bug,而IE的bug似乎比大多数浏览器都多.IE的表现与其他浏览器不同的原因之一就是,显示引擎使用一个称为布局(layout)的内部概念.   因为布局是专门针对显示引擎内部工作方 ...

  8. Android真机安装sqlite3的方法

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  9. 移动端页面 css reset

    这个是通用的  css reset.这个版本适用于 移动端页面 如果需要在 PC端使用,可以 修改 html{font-size: 10px;}为html{font-size: 12px;} 其他地方 ...

  10. Java 非线程安全的HashMap如何在多线程中使用

    Java 非线程安全的HashMap如何在多线程中使用 HashMap 是非线程安全的.在多线程条件下,容易导致死循环,具体表现为CPU使用率100%.因此多线程环境下保证 HashMap 的线程安全 ...