28452023-01-29 19:24:39VMGoJoNomekopcpp14Elfogadva 100/1002.065s4840 KiB
#include <bits/stdc++.h>
#include <cassert>
#include <signal.h>

#define N_MAX 4000

using namespace std;

int N;
int A[N_MAX + 5];
int D[N_MAX + 5];
int P[N_MAX + 5], ans[N_MAX + 5];

bool cmp(int a, int b) { return D[a] < D[b]; }

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    sort(A + 1, A + N + 1);

    long long ide;

    cout << "? ";
    for (int i = 1; i <= N; i++) {
        cout << A[i] << " ";
    }
    cout.flush();
    cin >> ide;

    bool first = true;
    int pos = -1;
    for (int i = 2; i <= N; i++) {
        if (A[i] != A[1]) {
            swap(A[i], A[1]);
            cout << "? ";
            for (int j = 1; j <= N; j++) {
                cout << A[j] << " ";
            }
            cout.flush();
            long long query;
            cin >> query;
            D[i] = (ide - query) / (A[1] - A[i]);
            swap(A[i], A[1]);
            if (first) {
                first = false;
                pos = i;
            }
        }
    }

    for (int i = 2; i < pos; i++) {
        swap(A[i], A[pos]);
        cout << "? ";
        for (int j = 1; j <= N; j++) {
            cout << A[j] << " ";
        }
        cout.flush();
        long long query;
        cin >> query;
        int dif = (ide - query) / (A[pos] - A[i]);
        D[i] = dif + D[pos];
        swap(A[i], A[pos]);
    }

    for (int i = 1; i <= N; i++) {
        P[i] = i;
    }
    sort(P + 1, P + N + 1, cmp);

    for (int i = 1; i <= N; i++) {
        ans[P[i]] = A[i];
    }

    cout << "! ";
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << " ";
    }
    cout.flush();
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva3ms1896 KiB
subtask210/10
2Elfogadva2ms2056 KiB
3Elfogadva2ms2140 KiB
subtask330/30
4Elfogadva4ms2340 KiB
5Elfogadva37ms2420 KiB
6Elfogadva37ms2648 KiB
7Elfogadva37ms2764 KiB
8Elfogadva4ms2956 KiB
9Elfogadva37ms3160 KiB
subtask420/20
10Elfogadva136ms3172 KiB
11Elfogadva136ms3504 KiB
12Elfogadva137ms3584 KiB
13Elfogadva141ms3584 KiB
subtask540/40
14Elfogadva2.065s3892 KiB
15Elfogadva2.062s4032 KiB
16Elfogadva1.824s4084 KiB
17Elfogadva1.577s4316 KiB
18Elfogadva2.061s4332 KiB
19Elfogadva2.063s4356 KiB
20Elfogadva2.062s4752 KiB
21Elfogadva2.025s4840 KiB