QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689630#7933. Build PermutationrgnerdplayerWA 0ms3520kbC++20920b2024-10-30 18:00:542024-10-30 18:01:01

Judging History

你现在查看的是最新测评结果

  • [2024-10-30 18:01:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3520kb
  • [2024-10-30 18:00:54]
  • 提交

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]