Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- ll a[300][300], ans[300][300], n;
- ll check(){
- ll anss = 0;
- for (int i = 0; i < n; i++)
- if (ans[i][0] + ans[i][1] - ans[0][0] - ans[0][1] > 0)
- anss++;
- return anss;
- }
- int main()
- {
- ll m;
- cin >> n >> m;
- m--;
- for (int i = 0; i < 2; i++)
- for (int j = 0; j < n; j++){
- cin >> a[j][i];
- a[j][i]--;
- }
- for (int i = 0; i <= n; i++){
- ll temp = 400;
- for (int j = 0; j < i; j++){
- ans[a[j][0]][0] = temp;
- temp--;
- }
- temp = n - i;
- for (int j = i; j < n; j++){
- ans[a[j][0]][0] = temp;
- temp--;
- }
- for (int j = 0; j < n; j++){
- temp = 400;
- for (int z = 0; z < j; z++){
- ans[a[z][1]][1] = temp;
- temp--;
- }
- temp = n - j;
- for (int z = j; z < n; z++){
- ans[a[z][1]][1] = temp;
- temp--;
- }
- if (check() == m){
- cout << "Possible" << endl;
- for (int f = 0; f < 2; f++){
- for (int z = 0; z < n; z++)
- cout << ans[a[z][f]][f] << " ";
- cout << endl;
- }
- return 0;
- }
- }
- }
- cout << "Impossible" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement