#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> a, mini, maxi;
int n;
void pitaj(){
cout << "query ";
for(int i = 0 ; i < n ; ++i){
cout << a[i];
if(i < n - 1){
cout << " ";
}
}
cout << endl;
cout.flush();
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0 ; i < n ; ++i){
int x;
cin >> x;
a.push_back(i + 1);
}
cout.flush();
do{
pitaj();
bool p;
cin >> p;
cout.flush();
if(p){
maxi = a;
if(mini.empty()){
mini = a;
}
}
}while(next_permutation(a.begin(), a.end()));
cout << "end" << endl;
cout.flush();
for(int i = 0 ; i < n ; ++i){
cout << mini[i] << ' ';
}
cout << endl;
for(int i = 0 ; i < n ; ++i){
cout << maxi[i] << ' ';
}
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
416 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
412 KB |
Output is correct |
5 |
Correct |
8 ms |
256 KB |
Output is correct |
6 |
Correct |
8 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3015 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3041 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3094 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |