#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 2e9;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;
int n, a[M], wr1 = inf, wr2, b[M];
bool ask(){
cout << "query ";
for(int i = 1; i <= n; ++i) cout << b[i] << " ";
cout << endl;
bool ret; cin >> ret;
return ret;
}
int main(){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i];
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
b[j] = a[j];
if(a[j] <= a[i]) ++b[j];
}
b[i] = 1;
if(!ask()) wr1 = a[i];
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
b[j] = a[j];
if(a[j] >= a[i]) --b[j];
}
b[i] = n;
if(!ask()) wr2 = a[i];
}
cout << "end\n";
int emp = 0; bool ok = 0;
for(int i = 1; i <= n; ++i){
if(!ok && a[i] == wr1){
emp = i;
cout << i + 1 << " ";
}
else if(a[i] == wr2){
if(emp) cout << emp << " ", emp = -1;
else cout << i << " ";
ok = 1;
}
else cout << i + (emp > 0) << " ";
}
cout << endl;
// cout << wr1 << " " << wr2 << endl;
emp = ok = 0;
for(int i = 1; i <= n; ++i){
if(!ok && a[i] == wr2){
emp = i;
cout << n - i << " ";;
}
else if(a[i] == wr1){
if(emp) cout << n - emp + 1 << " ", emp = -1;
else cout << n - i + 1 << " ";
ok = 1;
}
else cout << n - i + 1 - (emp > 0) << " ";
}
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |