//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
int n;
int it[101];
bool check(vector<int> aa){
cout<<"query ";
for(auto j:aa){
cout<<j<<" ";
}
cout<<endl;
int x;
cin>>x;
return x;
}
void answer(vector<int> aa,vector<int> bb){
cout<<"end"<<endl;
for(auto j:aa){
cout<<j<<" ";
}
cout<<endl;
for(auto j:bb){
cout<<j<<" ";
}
cout<<endl;
return;
}
void solve1(){
vector<int> ss;
for(int i=1;i<=n;i++){
ss.pb(i);
}
vector<int> ans;
vector<int> ans2;
while(true){
if(check(ss)){
if(ans.size()==0){
ans=ss;
}
ans2=ss;
}
if(next_permutation(ss.begin(),ss.end())){
continue;
}
else{
break;
}
}
answer(ans,ans2);
}
void solve2(){
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
vector<int> ss5;
vector<int> ss6;
/*for(int k=0;k<n;k++){
ss.pb(it[k]);
}*/
queue<int> tt;
for(int ii=3;ii<=n;ii++){
tt.push(ii);
}
for(int k=0;k<n;k++){
if(k==i){
if(it[i]<it[j]){
ss5.pb(2);
}
else{
ss5.pb(1);
}
if(it[i]>it[j]){
ss6.pb(2);
}
else{
ss6.pb(1);
}
}
else if(k==j){
if(it[i]>it[j]){
ss5.pb(2);
}
else{
ss5.pb(1);
}
if(it[i]<it[j]){
ss6.pb(2);
}
else{
ss6.pb(1);
}
}
else{
ss5.pb(tt.front());
ss6.pb(tt.front());
tt.pop();
}
}
int xx=check(ss5);
int yy=check(ss6);
//swap(ss[i],ss[j]);
if(xx+yy==1){
vector<int> aa;
vector<int> bb;
for(int k=1;k<=n;k++){
bb.pb(k);
aa.pb(n-k+1);
}
for(int ii=1;ii<=n;ii++){
for(int jj=1;jj<=n;jj++){
if(ii==jj){
continue;
}
if(ii<jj and it[i]>it[j]){
continue;
}
if(ii>jj and it[i]<it[j]){
continue;
}
// cout<<ii<<":"<<jj<<endl;
queue<int> ss;
for(int k=1;k<=n;k++){
if(k!=ii and k!=jj){
ss.push(k);
}
}
vector<int> cur;
for(int k=0;k<n;k++){
if(k==i){
cur.pb(ii);
continue;
}
else if(k==j){
cur.pb(jj);
continue;
}
cur.pb(ss.front());
ss.pop();
}
aa=min(aa,cur);
queue<int> ss2;
for(int k=n;k>=1;k--){
if(k!=ii and k!=jj){
ss2.push(k);
}
}
vector<int> cur2;
for(int k=0;k<n;k++){
if(k==i){
cur2.pb(ii);
continue;
}
else if(k==j){
cur2.pb(jj);
continue;
}
cur2.pb(ss2.front());
ss2.pop();
}
bb=max(bb,cur2);
}
}
answer(aa,bb);
return;
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(int i=0;i<n;i++){
cin>>it[i];
}
/* solve2();
return 0;*/
if(n<=6){
solve1();
}
if(n>=30 and n<=70){
solve2();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
7 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
364 KB |
Output is correct |
7 |
Correct |
10 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
364 KB |
Output is correct |
2 |
Correct |
42 ms |
364 KB |
Output is correct |
3 |
Correct |
34 ms |
376 KB |
Output is correct |
4 |
Correct |
12 ms |
364 KB |
Output is correct |
5 |
Correct |
6 ms |
392 KB |
Output is correct |
6 |
Correct |
34 ms |
364 KB |
Output is correct |
7 |
Correct |
7 ms |
364 KB |
Output is correct |
8 |
Correct |
4 ms |
364 KB |
Output is correct |
9 |
Correct |
52 ms |
364 KB |
Output is correct |
10 |
Correct |
15 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |