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 file contains several test cases. Each of them consists of six lines. Each line describes one pallet and contains two integer numbers w and h (1 ≤ w, h ≤ 10 000) — width and height of the pallet in millimeters respectively.

Output

For each test case, print one output line. Write a single word ‘POSSIBLE’ to the output file 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

1345 2584
2584 683
2584 1345
683 1345
683 1345
2584 683
1234 4567
1234 4567
4567 4321
4322 4567
4321 1234
4321 1234

Sample Output

POSSIBLE
IMPOSSIBLE

HINT

题目的意思是给我们六个矩形的长和宽,让我们判断能否构成一个长方体。考虑长方形的特点可知,总会有两个面的长和宽hi相等的,同时12个边中总会又出现至少每4个边是相等的。可以根据这两个条件来判断输入样例。

Accepted

#include<stdio.h>
#include<stdlib.h>
#include<string.h> int cmp(const void* a, const void* b)
{
return *(int*)a - *(int*)b;
} int main()
{
int a, b;
while (scanf("%d %d", &a, &b) != EOF)
{
int arr[12] = { 0 };
int arr2[6][2] = { 0 };
arr2[0][0] = a > b ? a : b;
arr2[0][1] = a > b ? b : a;
int j = 2;
arr[0] = a;arr[1] = b;
for (int i = 1;i < 6;i++)
{
scanf("%d %d", &a, &b);
arr2[i][0] = a > b ? a : b;
arr2[i][1] = a > b ? b : a;
arr[j++] = a;arr[j++] = b;
}
qsort(arr, 12, sizeof(int), cmp);
int flag = 0;
for (int i = 0;i < 12;i += 4)
for (int j = 0;j < 4;j++)
if (arr[i] != arr[j + i])
flag = 1;
if (!flag)
{
for (int i = 0;i < 6;i++)
{
int j;
if (!arr2[i][0])continue;
for (j = 0;j < 6;j++)
if (i != j && arr2[i][0] == arr2[j][0] && arr2[i][1] == arr2[j][1])
{
arr2[i][0] = arr2[j][0] = arr2[i][1] = arr2[j][1] = 0;
break;
}
if (j == 6)
{
flag = 1;
break;
}
}
}
printf("%s\n", flag == 0 ? "POSSIBLE" : "IMPOSSIBLE");
}
}

最新文章

  1. Android Butterknife 8.4.0 使用方法总结
  2. js判断浏览器类型以及浏览器版本
  3. iOS Crash常规跟踪方法及Bugly集成运用
  4. centos7 添加图形界面的功能
  5. windows 访问 ubuntu虚拟机 django服务器 失败
  6. Android App 开发常用的xUtils框架
  7. RC4加密解密算法
  8. ORACLE AUTOMATIC STORAGE MANAGEMENT翻译-第二章ASM Instance(4)完
  9. 【PHP框架CodeIgniter学习】使用辅助函数—建立自己的JSONHelper
  10. PHPUnit初试
  11. [Linux] PHP程序员玩转Linux系列-腾讯云硬盘扩容挂载
  12. 同形异义字:看我如何拿到TaoBao.com的解析权
  13. 免费好用的阿里云云盾证书服务(https证书)申请步骤
  14. HDU3488 Tour [有向环覆盖 费用流]
  15. Python——高阶函数——map filter zip
  16. Python module ---- abc
  17. String 常见的十种方法!
  18. 【bzoj1150】[CTSC2007]数据备份Backup 模拟费用流+链表+堆
  19. Android编码学习之Adapter
  20. JQuery学习二-字典操作

热门文章

  1. 学习js、jquery、vue实现部分组件
  2. CNN结构演变总结(一)经典模型
  3. 设置ViewPager 自动滑动时间,速度 方便展示动画
  4. 解决springboot项目打成jar包部署到linux服务器后上传图片无法访问的问题
  5. 剑指 Offer 33. 二叉搜索树的后序遍历序列 + 根据二叉树的后序遍历序列判断对应的二叉树是否存在
  6. 【Arduino学习笔记07】模拟信号的输入与输出 analogRead() analogWrite() map() constrain()
  7. FreeBSD 12.2 已经发布 从现有版本更新到12
  8. python两个字典相加
  9. All I know about A/B Test (1) : 均值型指标与比值(率)型指标的计算区别
  10. Linux+mysql混杂