# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310352 | galca | Zagonetka (COI18_zagonetka) | C++14 | 50 ms | 488 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 si, sj;
bool valid(vector<int>& perm) {
return true; // perm[si] < perm[sj];
}
int main() {
int n;
cin >> n;
int i, j;
vector<int> p(n);
for (i = 0; i < n; i++) {
cin >> p[i];
}
//cin >> si >> sj;
// assume 1 cond
bool found = false;
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
vector<int> q;
cout << "query";
int k;
for (k = 0; k < i; k++) {
cout << " " << p[k];
q.push_back(p[k]);
}
cout << " " << p[j];
q.push_back(p[j]);
++k;
for (; k < j; k++) {
cout << " " << p[k];
q.push_back(p[k]);
}
cout << " " << p[i];
q.push_back(p[i]);
++k;
for (; k < n; k++) {
cout << " " << p[k];
q.push_back(p[k]);
}
cout << endl; // endl auto-flushes
int result1 = valid(q);
//cin >> result1;
if (!result1) {
found = true;
break;
}
}
if (found) {
break;
}
}
vector<int> minp(n);
vector<int> maxp(n);
cout << "end" << endl;
int k;
int minval = 0;
int maxval = n-1;
int first = i < j ? i : j;
int second = i < j ? j : i;
for (k = 0; k < first; k++) {
minp[k] = minval++;
maxp[k] = maxval--;
}
if (k == n - 1) {
minp[k] = minval++;
maxp[k] = maxval--;
}
else {
if (p[i] < p[j]) {
minp[first] = minval++;
minp[second] = minval++;
maxp[second] = maxval--;
maxp[first] = maxval--;
for (int l = first + 1; l < second; l++) {
minp[l] = minval++;
maxp[l] = maxval--;
}
}
else {
minp[second] = minval++;
minp[first] = minval++;
maxp[first] = maxval--;
maxp[second] = maxval--;
for (int l = first + 1; l < second; l++) {
minp[l] = minval++;
maxp[l] = maxval--;
}
}
for (k = second + 1; k < n; k++) {
minp[k] = minval++;
maxp[k] = maxval--;
}
}
for (k=0; k < n; k++) {
cout << " " << minp[k]+1;
}
cout << endl;
for (k = 0; k < n; k++) {
cout << " " << maxp[k]+1;
}
cout << endl; // endl auto-flushes
return 0;
}
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... |