0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 02:58:48 +00:00

B - Special Permutation

https://codeforces.com/contest/1612/submission/136448114
This commit is contained in:
Baoshuo Ren 2021-11-22 18:30:42 +08:00 committed by Baoshuo Ren
parent 6cb4515b21
commit 53d51ed170
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

45
CodeForces/1612/B/B.cpp Normal file
View File

@ -0,0 +1,45 @@
#include <bits/stdc++.h>
using namespace std;
int t, n, a, b;
bool flag, flag_a, flag_b;
vector<int> ans_left, ans_right;
int main() {
cin >> t;
while (t--) {
flag = flag_a = flag_b = false;
ans_left.clear();
ans_right.clear();
cin >> n >> a >> b;
for (int i = n; i > 0; i--) {
if (i == a) {
ans_left.push_back(i);
flag_a = true;
} else if (i == b) {
ans_right.push_back(i);
flag_b = true;
} else if (i > a && ans_left.size() + !flag_a < n / 2) {
ans_left.push_back(i);
} else if (i < b && ans_right.size() + !flag_b < n / 2) {
ans_right.push_back(i);
} else {
flag = true;
break;
}
}
if (flag) {
cout << -1 << endl;
} else {
for (int ans : ans_left) {
cout << ans << ' ';
}
for (int ans : ans_right) {
cout << ans << ' ';
}
cout << endl;
}
}
return 0;
}