QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#689630 | #7933. Build Permutation | rgnerdplayer | WA | 0ms | 3520kb | C++20 | 920b | 2024-10-30 18:00:54 | 2024-10-30 18:01:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&]() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> o(n);
iota(o.begin(), o.end(), 0);
sort(o.begin(), o.end(), [&](int i, int j) { return a[i] < a[j]; });
for (int i = 0; i < n; i++) {
if (a[o[0]] + a[o[n - 1]] != a[o[i]] + a[o[n - 1]]) {
cout << "-1\n";
return;
}
}
vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[o[i]] = o[n - 1 - i];
}
for (int i = 0; i < n; i++) {
cout << ans[i] + 1 << " \n"[i + 1 == n];
}
};
solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3520kb
input:
5 4 2 5 1 3
output:
-1
result:
wrong answer Integer -1 violates the range [1, 5]