Submission #967538

# Submission time Handle Problem Language Result Execution time Memory
967538 2024-04-22T11:23:19 Z lanaskarica Zagonetka (COI18_zagonetka) C++14
0 / 100
2 ms 452 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];

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 solve1() {
    cout << "query ";
    for (int i = 1; i <= n; i++) cout << i << " ";
    cout << endl;
    cin >> a;
    rjesi(a);
}

//void solve1() {}

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

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

    solve1();
    //else solve2();

    return 0;
}

Compilation message

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