Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <cstdio>
  2. #include <stdio.h>
  3. #include <vector>
  4. #include <cmath>
  5. #include <string.h>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <string>
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. vector <int> w(6);
  14. vector <int> h(6);
  15. vector <vector <int> > same(10000,vector<int> (10000));
  16. vector <int> amount(10000,0);
  17. for (int i =0;i<6;++i) {
  18. cin>> w[i]>>h[i];
  19. same[w[i]][h[i]]++;
  20. same[h[i]][w[i]]++;
  21. amount[w[i]]=w[i];
  22. amount[h[i]]=h[i];
  23. }
  24. int result=0;
  25. for (int i =0;i<amount.size();++i) {
  26. if (amount[i]!=0) result++;
  27. }
  28. if (result == 1) {
  29. cout << "POSSIBLE";
  30. return 0;
  31. }
  32. if (result >3) {
  33. cout << "IMPOSSIBLE";
  34. return 0;
  35. }
  36. bool pr=true;
  37. if (result ==3) {
  38. for (int i =0;i<6;++i) {
  39. if (same[w[i]][h[i]]!=2)
  40. pr=false;
  41. }
  42. if (pr) cout << "POSSIBLE"; else cout << "IMPOSSIBLE";
  43. return 0;
  44. }
  45. int p=0;
  46. if (result ==2) {
  47. for (int i=0; i<6;++i) {
  48. if (same[w[i]][h[i]]==4)
  49. p++;
  50. if (same[w[i]][h[i]]==2) p++;
  51. }
  52. if (p==2) cout << "POSSIBLE"; else cout << "IMPOSSIBLE";
  53. return 0;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement