답안 #144634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144634 2019-08-17T09:59:22 Z SamAnd Zagonetka (COI18_zagonetka) C++17
9 / 100
11 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 102;

int n;
int a[N];

int minu[N], maxu[N];

bool qry(int a[])
{
    cout << "query";
    for (int k = 1; k <= n; ++k)
        cout << ' ' << a[k];
    cout << endl;
    int x;
    cin >> x;
    return x;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    if (n <= 6)
    {
        for (int i = 1; i <= n; ++i)
            minu[i] = maxu[i] = a[i];
        sort(a + 1, a + n + 1);
        do
        {
            if (qry(a))
            {
                for (int i = 1; i <= n; ++i)
                {
                    if (a[i] == minu[i])
                        continue;
                    if (a[i] < minu[i])
                    {
                        for (int j = 1; j <= n; ++j)
                            minu[j] = a[j];
                    }
                    break;
                }
                for (int i = 1; i <= n; ++i)
                {
                    if (a[i] == maxu[i])
                        continue;
                    if (a[i] > maxu[i])
                    {
                        for (int j = 1; j <= n; ++j)
                            maxu[j] = a[j];
                    }
                    break;
                }
            }
        } while (next_permutation(a + 1, a + n + 1));
        cout << "end" << endl;
        for (int i = 1; i <= n; ++i)
            cout << minu[i] << ' ';
        cout << endl;
        for (int i = 1; i <= n; ++i)
            cout << maxu[i] << ' ';
        cout << endl;
    }
    else
    {
        for (int i = 1; i <= n; ++i)
        {
            for (int j = i + 1; j <= n; ++j)
            {
                swap(a[i], a[j]);
                if (qry(a) == 0)
                {
                    swap(a[i], a[j]);
                    cout << "end" << endl;
                    if (a[i] < a[j])
                    {
                        for (int k = 1; k <= n; ++k)
                            cout << k << ' ';
                        cout << endl;
                        int z = n + 1;
                        int t;
                        for (int k = 1; k <= n; ++k)
                        {
                            if (k == i)
                            {
                                cout << z - 2 << ' ';
                                t = z - 1;
                                z -= 2;
                                continue;
                            }
                            if (k == j)
                            {
                                cout << t << ' ';
                                continue;
                            }
                            cout << --z << ' ';
                        }
                        cout << endl;
                    }
                    else
                    {
                        int z = 0;
                        int t;
                        for (int k = 1; k <= n; ++k)
                        {
                            if (k == i)
                            {
                                cout << z + 2 << ' ';
                                t = z + 1;
                                z += 2;
                                continue;
                            }
                            if (k == j)
                            {
                                cout << t << ' ';
                                continue;
                            }
                            cout << ++z << ' ';
                        }
                        cout << endl;
                        for (int k = 1; k <= n; ++k)
                            cout << n - k + 1 << ' ';
                        cout << endl;
                    }
                    return 0;
                }
                swap(a[i], a[j]);
            }
        }
    }
    return 0;
}

Compilation message

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:118:46: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
                                 cout << t << ' ';
                                              ^~~
zagonetka.cpp:96:46: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
                                 cout << t << ' ';
                                              ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 11 ms 248 KB Output is correct
6 Correct 10 ms 252 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -