Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int a[1010][1010], d[1010][1010];
- int main()
- {
- int x, y;
- cin >> x >> y;
- --y;
- for(int i = 0; i < x; ++i)
- cin >> a[i][0], --a[i][0];
- for(int i = 0; i < x; ++i)
- cin >> a[i][1], --a[i][1];
- for(int i = 0; i <= x; ++i)
- {
- int mx = 400;
- for(int j = 0; j < i; ++j)
- d[a[j][0]][0] = mx, --mx;
- mx = x - i;
- for(int j = i; j < x; ++j)
- d[a[j][0]][0] = mx, --mx;
- for(int j = 0; j <= x; ++j)
- {
- mx = 400;
- for(int k = 0; k < j; ++k)
- d[a[k][1]][1] = mx, -mx;
- mx = x - j;
- for(int k = j; k < x; ++k)
- d[a[k][1]][1] = mx, --mx;
- int p = 0;
- for(int k = 0; k < x; ++k)
- if(d[k][0] + d[k][1] - d[0][0] - d[0][1] > 0)
- ++p;
- if(p == y)
- {
- cout << "Possible" << endl;
- for(int q = 0; q < x; ++q)
- cout << d[a[q][0]][0] << " ";
- cout << endl;
- for(int q = 0; q < x; ++q)
- cout << d[a[q][1]][1] << " ";
- cout << endl;
- return 0;
- }
- }
- }
- cout << "Impossible\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement