Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. struct rect
  7. {
  8. int w;
  9. int h;
  10. };
  11.  
  12. bool sortRect(const rect &r1, const rect &r2)
  13. {
  14. if(r1.w != r2.w)
  15. {
  16. return r1.w > r2.w;
  17. }
  18. else
  19. {
  20. return r1.h > r2.h;
  21. }
  22. }
  23.  
  24. int main()
  25. {
  26. rect rects[6];
  27. while(cin >> rects[0].w && cin >> rects[0].h)
  28. {
  29. if(rects[0].w < rects[0].h)
  30. {
  31. swap(rects[0].w, rects[0].h);
  32. }
  33.  
  34. for(int i = 1 ; i <= 5;++i)
  35. {
  36. cin >> rects[i].w >> rects[i].h;
  37. if(rects[i].w < rects[i].h)
  38. {
  39. swap(rects[i].w, rects[i].h);
  40. }
  41. }
  42.  
  43. sort(rects, rects + 6, sortRect );
  44. if(rects[0].w != rects[1].w || rects[0].h != rects[1].h ||
  45. rects[2].w != rects[3].w || rects[2].h != rects[3].h ||
  46. rects[4].w != rects[5].w || rects[4].h != rects[5].h
  47. )
  48. {
  49. printf("IMPOSSIBLE\n");
  50. }
  51. else if(rects[0].w != rects[2].w || rects[0].h != rects[4].w || rects[2].h != rects[4].h)
  52. {
  53. printf("IMPOSSIBLE\n");
  54. }
  55. else
  56. {
  57. printf("POSSIBLE\n");
  58. }
  59. }
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement