제출 #1358966

#제출 시각아이디문제언어결과실행 시간메모리
1358966gkos5678Zagonetka (COI18_zagonetka)C++20
0 / 100
21 ms432 KiB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define all(v) v.begin(), v.end()
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef vector<ii> vii;

const int maxn = 105;

int n, p[maxn], q[maxn], mnp[maxn], mxp[maxn];
vii ost;

int qu(){
    cout << "query ";
    for (int i = 1; i <= n; i++) cout << q[i] << " ";
    cout << endl;
    int res;
    cin >> res;
    return res;
}

void okemin(){
    for (int i = 1; i <= n; i++) mnp[i] = q[i];
}

void okemax(){
    for (int i = 1; i <= n; i++) mxp[i] = q[i];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> p[i];

    for (int i = n - 1; i > 0; i--){
        for (int j = i + 1; j <= n; j++){
            for (int k = 1; k < i; k++)
                q[k] = k;
            q[j] = i;
            for (int k = i; k < j; k++)
                q[k] = k + 1;
            for (int k = j + 1; k <= n; k++)
                q[k] = k;
            if (qu()) okemin();
            for (int k = 1; k < i; k++)
                q[k] = n + 1 - k;
            q[j] = n + 1 - i;
            for (int k = i; k < j; k++)
                q[k] = n - k;
            for (int k = j + 1; k <= n; k++)
                q[k] = n + 1 - k;
            if (qu()) okemax();
        }
    }
    for (int i = 1; i <= n; i++)
        q[i] = i;
    if (qu())
        okemin();
    for (int i = 1; i <= n; i++)
        q[i] = n + 1 - i;
    if (qu())
        okemax();

    cout << "end\n";
    for (int i = 1; i <= n; i++)
        cout << mnp[i] << " ";
    cout << "\n";
    for (int i = 1; i <= n; i++)
        cout << mxp[i] << " ";
    cout << endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...