Submission #967542

# Submission time Handle Problem Language Result Execution time Memory
967542 2024-04-22T11:59:11 Z lanaskarica Zagonetka (COI18_zagonetka) C++14
9 / 100
3 ms 596 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair <int, int>
#define fi first
#define se second

const int MAXN = 110;

int n, a, p[MAXN], bio[MAXN];

bool nes;
vector <int> perm, rj1, rj2;

int pro(int br, int idx) {
    if (idx == 0) return br + 1;
    else return br - 1;
}

void isprobaj(int i, int j, int idx) {
    int br = 1, d;
    if (idx == 1) br = n;
    for (int z = 1; z <= n; z++) {
        if (z != i && z != j) {cout << br << " "; br = pro(br, idx); continue;}
        if (z == i) {d = br; br = pro(br, idx); cout << br << " "; br = pro(br, idx);}
        else {cout << d << " ";}
    }
    cout << endl;
}

void rjesi(int idx) {
    bool bl = 0;
    for (int i = n; i > 0; i--) {
        for (int j = i - 1; j >= 0; j--) {

            cout << "query ";
            isprobaj(j, i, idx);
            cin >> a;
            if (a == 0) continue;

            if (idx == 1) {
                cout << "end" << endl;
                for (int i = 1; i <= n; i++) cout << i << " "; cout << endl;
                isprobaj(j, i, idx);
            }
            else {
                cout << "end\n";
                isprobaj(j, i, idx);
                for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; cout << endl;
            }
            bl = 1;
            break;
        }
        if (bl == 1) break;
    }
}

void solve2() {
    cout << "query ";
    for (int i = 1; i <= n; i++) cout << i << " ";
    cout << endl;
    cin >> a;
    rjesi(a);
}

void rek(int x) {
    if (x == n) {
        cout << "query ";
        for (auto e : perm) cout << e << " ";
        cout << endl;
        cin >> a;
        if (a == 1) {
            rj2.clear();
            for (auto e : perm) {
                rj2.push_back(e);
                if (nes == 0) rj1.push_back(e);
            }
            nes = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (bio[i] == 1) continue;
        bio[i] = 1;
        perm.push_back(i);
        rek(x + 1);
        perm.pop_back();
        bio[i] = 0;
    }
}

void solve1() {
    nes = 0;
    rek(0);
    cout << "end" << endl;
    for (auto e : rj1) cout << e << " ";
    cout << endl;
    for (auto e : rj2) cout << e << " ";
    cout << endl;
}

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

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

    if (n <= 6) solve1();
    else solve2();

    return 0;
}

Compilation message

zagonetka.cpp: In function 'void rjesi(int)':
zagonetka.cpp:44:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |                 for (int i = 1; i <= n; i++) cout << i << " "; cout << endl;
      |                 ^~~
zagonetka.cpp:44:64: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |                 for (int i = 1; i <= n; i++) cout << i << " "; cout << endl;
      |                                                                ^~~~
zagonetka.cpp:50:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   50 |                 for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; cout << endl;
      |                 ^~~
zagonetka.cpp:50:72: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |                 for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; cout << endl;
      |                                                                        ^~~~
zagonetka.cpp: In function 'void isprobaj(int, int, int)':
zagonetka.cpp:27:28: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |         else {cout << d << " ";}
      |                            ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 452 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -