Submission #240773

# Submission time Handle Problem Language Result Execution time Memory
240773 2020-06-21T07:16:47 Z NONAME Zagonetka (COI18_zagonetka) C++14
9 / 100
12 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e5 + 500;

int n, p[N];
vector <int> cur, mn, mx;
bool mk[N];

bool gd(vector <int> q) {
    cout << "query ";
    for (int i : q)
        cout << i << " ";
    cout << endl;
    
    bool x;
    cin >> x;
    return x;
}

void upd(vector <int> &v1, vector <int> v2, bool f) {
    if (v1.empty()) {
        v1 = v2;
        return;
    }
    
    int i = 0;
    while (i < n) {
        if (v1[i] != v2[i])
            break;
            
        ++i;
    }
    
    if (i == n)
        return;
        
    if (f && v2[i] > v1[i])
        v1 = v2;
        
    if (!f && v2[i] < v1[i])
        v1 = v2;
}

void rec(int k) {
    if (k == n) {
        if (gd(cur)) {
            upd(mn, cur, 0);
            upd(mx, cur, 1);
        }
        
        return;
    }
    
    for (int i = 1; i <= n; ++i) {
        if (mk[i])
            continue;
            
        cur.push_back(i);
        mk[i] = 1;
        rec(k + 1);
        mk[i] = 0;
        cur.pop_back();
    }
}

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

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> p[i];
        
    if (n <= 6) {
        rec(0);
        
        cout << "end" << endl;
        for (int i : mn)
            cout << i << " ";
        cout << endl;
        
        for (int i : mx)
            cout << i << " ";
        cout << endl;
        
        return 0;
    }
    
    cout << "end" << endl;
    for (int i = 1; i <= n; ++i)
        cout << i << " ";
    cout << endl;
    
    for (int i = n; i >= 1; --i)
        cout << i << " ";
    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 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 12 ms 384 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -