# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310232 | galca | Zagonetka (COI18_zagonetka) | C++14 | 2 ms | 256 KiB |
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 <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i];
}
// assume 1 cond
int i, j;
bool found = false;;
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
cout << "query";
int k;
for (k = 0; k < i; k++) {
cout << " " << p[k];
}
cout << " " << p[j];
++k;
for (; k < j; k++) {
cout << " " << p[k];
}
cout << " " << p[i];
++k;
for (; k < n; k++) {
cout << " " << p[k];
}
cout << endl; // endl auto-flushes
int result1;
cin >> result1;
if (!result1) {
found = true;
break;
}
}
if (found) {
break;
}
}
vector<int> minp(n);
vector<int> maxp(n);
cout << "end";
int k;
int minval = 0;
int maxval = n-1;
for (k = 0; k < i; k++) {
minp[k] = minval++;
maxp[k] = maxval--;
}
if (p[i] < p[j]) {
minp[i] = minval++;
maxp[j] = maxval--;
for (int l = i + 1; l < j; l++) {
minp[l] = minval++;
maxp[l-1] = maxval--;
}
minp[j] = minval++;
}
else {
minp[j] = minval++;
maxp[i] = maxval--;
for (int l = i + 1; l < j; l++) {
minp[l-1] = minval++;
maxp[l] = maxval--;
}
maxp[i] = maxval--;
}
for (k = j+1; k < n; k++) {
minp[k] = minval++;
maxp[k] = maxval--;
}
for (k=0; k < n; k++) {
cout << minp[k] << " ";
}
cout << endl;
for (k = 0; k < n; k++) {
cout << maxp[k] << " ";
}
cout << endl; // endl auto-flushes
if (i < n) {
//
}
}
Compilation message (stderr)
# | 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... |