This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
if (n <= 70) solve1();
//else solve2();
return 0;
}
Compilation message (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |