88032024-01-31 09:32:17Error42Nomekopcpp17Wrong answer 0/1001.419s5036 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;

struct nomekop {
    ll pos, delta_attack, companion;
    bool done;
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;

    vector<ll> a(n);
    for (ll& x : a)
        cin >> x;

    // all same
    if (count(a.begin(), a.end(), a[0]) == n) {
        cout << "!";

        for (int i = 0; i < n; i++)
            cout << " " << a[i];

        cout << endl;

        return 0;
    }

    cout << "?";

    for (int i = 0; i < n; i++)
        cout << " " << a[i];

    cout << endl;

    ll baseline;
    cin >> baseline;

    vector<nomekop> opponents(n);

    auto const test_against = [&](int const f) {
        for (int i = 0; i < n; i++) {
            if (i == f || a[i] == a[f] || opponents[i].done)
                continue;

            cout << "?";

            for (int j = 0; j < n; j++) {
                cout << " ";
                if (j == i)
                    cout << a[f];
                else if (j == f)
                    cout << a[i];
                else
                    cout << a[j];
            }

            cout << endl;

            ll cur;
            cin >> cur;

            ll delta = cur - baseline;

            opponents[i].pos = i;
            opponents[i].delta_attack = delta / (a[f] - a[i]);

            opponents[i].done = true;
        }
    };

    test_against(0);

    for (int i = 1; i < n; i++) {
        if (a[i] != a[0]) {
            test_against(i);
            break;
        }
    }

    sort(opponents.begin(), opponents.end(), [&](nomekop const& a, nomekop const& b) {
        return a.delta_attack < b.delta_attack;
    });

    sort(a.begin(), a.end());

    for (int i = 0; i < n; i++)
        opponents[i].companion = a[i];

    sort(opponents.begin(), opponents.end(), [&](nomekop const& a, nomekop const& b) {
        return a.pos < b.pos;
    });

    cout << "!";

    for (nomekop const& x : opponents)
        cout << " " << x.companion;
    cout << endl;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1696 KiB
subtask20/10
2Wrong answer3ms2004 KiB
3Wrong answer3ms2092 KiB
subtask30/30
4Wrong answer4ms2316 KiB
5Wrong answer28ms2688 KiB
6Wrong answer28ms2552 KiB
7Wrong answer28ms2808 KiB
8Wrong answer4ms2868 KiB
9Wrong answer28ms3240 KiB
subtask40/20
10Wrong answer97ms3568 KiB
11Wrong answer97ms3440 KiB
12Wrong answer97ms3800 KiB
13Wrong answer97ms3696 KiB
subtask50/40
14Wrong answer1.406s4200 KiB
15Wrong answer1.419s4532 KiB
16Wrong answer1.25s4272 KiB
17Wrong answer1.085s4472 KiB
18Wrong answer1.389s4760 KiB
19Wrong answer1.388s4804 KiB
20Accepted1.389s5036 KiB
21Wrong answer1.381s4736 KiB