Submission #168003

# Submission time Handle Problem Language Result Execution time Memory
168003 2019-12-11T06:52:43 Z egekabas Zagonetka (COI18_zagonetka) C++14
0 / 100
58 ms 400 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
int n;
int a[109];
int big[109][109];
int small[109][109];
int q(int idx, int put){
    cout << "query ";
    for(int i = 0; i <= put; ++i){
        if(i == idx) continue;
        cout << a[i] << " ";
    }
    cout << a[idx] << " ";
    for(int i = put+1; i < n; ++i){
        if(i == idx) continue;
        cout << a[i] << " ";    
    }
    cout << endl;
    int t1;
    cin >> t1;
    return t1;
}
void sf(int l, int r){
    if(l >= r)
        return;
    int look = a[l];
    int lid = l;
    for(int i = l+1; i <= r; ++i){
        if(big[look][a[i]] == 1){
            swap(a[lid], a[i]);
            swap(a[i], a[lid+1]);
            ++lid;
        }
    }
    sf(l, lid-1);
    sf(lid+1, r);
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n-1; ++i){
        for(int j = n-1; j > i; --j){
            if(q(i, j) == 1){
                for(int k = j+1; k < n; ++k)
                    big[k][i] = small[i][k] = 1;
                goto END;
            }
        }
        for(int k = i+1; k < n; ++k)
            big[k][i] = small[i][k] = 1;
        END:;
    }
    cout << "end\n";
    sort(a, a+n);
    sf(0, n-1);
    for(int i = 0; i < n; ++i)
        cout << a[i] << " ";
    cout << "\n";
    sort(a, a+n, greater<int>());
    sf(0, n-1);
    for(int i = 0; i < n; ++i)
        cout << a[i] << " ";
    cout << "\n";
    
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -