# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
242927 | MatesV13 | Zagonetka (COI18_zagonetka) | C++11 | 14 ms | 512 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 <bits/stdc++.h>
using namespace std;
long long n, x, starix, prvi, drugi;
vector<int> ansmin, ansmax, cur;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=0; i<n; i++) cin >> x;
for (int i=1; i<=n; i++) cur.push_back(i);
ansmax.resize(n, 0);
if (n<7){
do {
cout << "query";
for (int i=0; i<n; i++) cout << " " << cur[i];
cout << endl << flush; cin >> x;
if (x){
if (ansmin.empty())
ansmin=cur;
ansmax=cur;
}
} while(next_permutation(cur.begin(), cur.end()));
cout << "end" << endl;
for (int i=0; i<n; i++) cout << ansmin[i] << " "; cout << endl;
for (int i=0; i<n; i++) cout << ansmax[i] << " "; cout << endl << flush;
}
else {
cout << "query";
for (int i=0; i<n; i++) cout << " " << cur[i];
cout << endl << flush; cin >> starix;
for (int i=0; i<n-1; i++) swap(cur[i], cur[i+1]);
for (int i=1; i<=n; i++){
cout << "query";
for (int i=0; i<n; i++) cout << " " << cur[i];
cout << endl << flush; cin >> x;
if (x==0 and starix==1) prvi=i;
if (x==1 and starix==0) drugi=i;
starix=x; for (int i=0; i<n-1; i++) swap(cur[i], cur[i+1]);
}
cout << "end" << endl;
// cout << prvi << " " << drugi << endl;
for (int i=1; i<=n; i++){
if (i==drugi and drugi<prvi) continue;
else if (i==prvi and drugi<prvi) cout << prvi << " " << drugi << " ";
else cout << i << " ";
} cout << endl;
for (int i=n; i>0; i--){
if (i==drugi and prvi<drugi) continue;
else if (i==prvi and prvi<drugi) cout << prvi << " " << drugi << " ";
else cout << i << " ";
} cout << endl << flush;
}
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... |