Submission #240790

# Submission time Handle Problem Language Result Execution time Memory
240790 2020-06-21T07:52:18 Z Vimmer Zagonetka (COI18_zagonetka) C++14
9 / 100
86 ms 384 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 101001
#define M ll(998244353)
#define inf 1e9 + 1e9


using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 3> a3;

//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector <int> mn, mx, g;

int n, mk[N], kl[N];

bool gd(vector <int> &g)
{
    cout << "query ";

    for (auto it : g) cout << it << " "; cout << endl;

    bool t;

    cin >> t;

    return t;
}

bool lower(vector <int> &a, vector <int> &b)
{
    for (int i = 0; i < sz(a); i++)
    {
        if (a[i] == b[i]) continue;

        return a[i] < b[i];
    }

    return 1;
}

void rec(int v)
{
    if (v == n)
    {
        if (gd(g))
        {
            if (sz(mn) == 0 || lower(g, mn)) mn = g;

            if (sz(mx) == 0 || lower(mx, g)) mx = g;
        }

        return;
    }

    for (int i = 1; i <= n; i++)
    {
        if (mk[i]) continue;

        mk[i] = 1;

        g.pb(i);

        rec(v + 1);

        g.pop_back();

        mk[i] = 0;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;

    vector <int> vr(n);

    for (int i = 0; i < n; i++) cin >> vr[i];

    if (n <= 6)
    {
        rec(0);

        cout << "end" << endl;

        for (auto it : mn) cout << it << " "; cout << endl;

        for (auto it : mx) cout << it << " "; cout << endl;

        exit(0);
    }

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            swap(vr[i], vr[j]);

            if (!gd(vr)) {kl[i]++; kl[j]++;}

            swap(vr[i], vr[j]);
        }

    set <pair <int, int> > se; se.clear();

    for (int i = 0; i < n; i++) se.insert({kl[i], i});

    int l = (*se.rbegin()).S;

    se.erase(*se.rbegin());

    int r = (*se.rbegin()).S;

    for (int i = 1; i <= n; i++) mn.pb(i);

    for (int i = n; i >= 1; i--) mx.pb(i);

    if (l < r)
    {
        swap(mx[l], mx[l + 1]);

        swap(mx[l + 1], mx[r]);

        sort(mx.begin() + l + 1, mx.end() - (n - r));

        reverse(mx.begin() + l + 1, mx.end() - (n - r));
    }
    else
    {
        swap(mn[r], mn[r + 1]);

        swap(mn[r + 1], mn[l]);

        sort(mn.begin() + r + 1, mn.end() - (n - l));
    }

    cout << "end" << endl;

    for (auto it : mn) cout << it << " "; cout << endl;

    for (auto it : mx) cout << it << " "; cout << endl;
}

Compilation message

zagonetka.cpp: In function 'bool gd(std::vector<int>&)':
zagonetka.cpp:38:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (auto it : g) cout << it << " "; cout << endl;
     ^~~
zagonetka.cpp:38:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (auto it : g) cout << it << " "; cout << endl;
                                          ^~~~
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:107:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for (auto it : mn) cout << it << " "; cout << endl;
         ^~~
zagonetka.cpp:107:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         for (auto it : mn) cout << it << " "; cout << endl;
                                               ^~~~
zagonetka.cpp:109:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for (auto it : mx) cout << it << " "; cout << endl;
         ^~~
zagonetka.cpp:109:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         for (auto it : mx) cout << it << " "; cout << endl;
                                               ^~~~
zagonetka.cpp:159:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (auto it : mn) cout << it << " "; cout << endl;
     ^~~
zagonetka.cpp:159:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (auto it : mn) cout << it << " "; cout << endl;
                                           ^~~~
zagonetka.cpp:161:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (auto it : mx) cout << it << " "; cout << endl;
     ^~~
zagonetka.cpp:161:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (auto it : mx) cout << it << " "; cout << endl;
                                           ^~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 15 ms 384 KB Output is correct
7 Correct 11 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -