Advertisement
Danlys506

Untitled

May 28th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int a[1010][1010], d[1010][1010];
  6.  
  7. void write()
  8. {
  9. cout << "Impossible\n";
  10. }
  11.  
  12. int main()
  13. {
  14. int x, y;
  15. cin >> x >> y;
  16. --y;
  17. for(int i = 0; i < x; ++i)
  18. cin >> a[i][0], --a[i][0];
  19.  
  20. for(int i = 0; i < x; ++i)
  21. cin >> a[i][1], --a[i][1];
  22.  
  23. /*sort(&a[0][0], &a[0][0] + x);
  24. sort(&a[1][0], &a[1][0] + x);*/
  25.  
  26. for(int i = 0; i <= x; ++i)
  27. {
  28. int mx = 400;
  29. for(int j = 0; j < i; ++j)
  30. d[a[j][0]][0] = mx, --mx;
  31.  
  32. mx = x - i;
  33.  
  34. for(int j = i; j < x; ++j)
  35. d[a[j][0]][0] = mx, --mx;
  36.  
  37. for(int j = 0; j <= x; ++j)
  38. {
  39. mx = 400;
  40. for(int k = 0; k < j; ++k)
  41. d[a[k][1]][1] = mx, -mx;
  42.  
  43. mx = x - j;
  44.  
  45. for(int k = j; k < x; ++k)
  46. d[a[k][1]][1] = mx, --mx;
  47.  
  48. int p = 0;
  49. int w = d[0][0], e = d[0][1];
  50.  
  51. for(int k = 0; k < x; ++k)
  52. if(d[k][0] - w + d[k][1] - e > 0)
  53. ++p;
  54.  
  55. if(p == y)
  56. {
  57. cout << "Possible" << endl;
  58. for(int q = 0; q < x; ++q)
  59. cout << d[a[q][0]][0] << " ";
  60. cout << endl;
  61. for(int q = 0; q < x; ++q)
  62. cout << d[a[q][1]][1] << " ";
  63. cout << endl;
  64. return 0;
  65. }
  66. }
  67. }
  68. write();
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement