Advertisement
Dennnhhhickk

Untitled

May 31st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. ll a[300][300], ans[300][300], n;
  6. ll check(){
  7. ll anss = 0;
  8. for (int i = 0; i < n; i++)
  9. if (ans[i][0] + ans[i][1] - ans[0][0] - ans[0][1] > 0)
  10. anss++;
  11. return anss;
  12. }
  13.  
  14. int main()
  15. {
  16. ll m;
  17. cin >> n >> m;
  18. m--;
  19. for (int i = 0; i < 2; i++)
  20. for (int j = 0; j < n; j++){
  21. cin >> a[j][i];
  22. a[j][i]--;
  23. }
  24. for (int i = 0; i <= n; i++){
  25. ll temp = 400;
  26. for (int j = 0; j < i; j++){
  27. ans[a[j][0]][0] = temp;
  28. temp--;
  29. }
  30. temp = n - i;
  31. for (int j = i; j < n; j++){
  32. ans[a[j][0]][0] = temp;
  33. temp--;
  34. }
  35. for (int j = 0; j < n; j++){
  36. temp = 400;
  37. for (int z = 0; z < j; z++){
  38. ans[a[z][1]][1] = temp;
  39. temp--;
  40. }
  41. temp = n - j;
  42. for (int z = j; z < n; z++){
  43. ans[a[z][1]][1] = temp;
  44. temp--;
  45. }
  46. if (check() == m){
  47. cout << "Possible" << endl;
  48. for (int f = 0; f < 2; f++){
  49. for (int z = 0; z < n; z++)
  50. cout << ans[a[z][f]][f] << " ";
  51. cout << endl;
  52. }
  53. return 0;
  54. }
  55. }
  56. }
  57. cout << "Impossible" << endl;
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement