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];
- void write()
- {
- cout << "Impossible\n";
- }
- 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];
- /*sort(&a[0][0], &a[0][0] + x);
- sort(&a[1][0], &a[1][0] + x);*/
- 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;
- int w = d[0][0], e = d[0][1];
- for(int k = 0; k < x; ++k)
- if(d[k][0] - w + d[k][1] - e > 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;
- }
- }
- }
- write();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement