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;
const int N = 105;
int n, a[N], b[N], s[N];
bool edge[N][N];
bool ask(int* q){
cout << "query ";
for (int i = 0; i < n; i ++){
cout << q[i] << " ";
}
cout << endl;
bool res;
cin >> res;
return res;
}
int main(){
cin >> n;
for (int i = 0; i < n; i ++)
cin >> a[i], s[i] = b[i] = a[i];
for (int i = 0; i < n; i ++){
for (int j = i + 1; j < n; j ++){
if (a[i] < a[j]){
swap(a[i], a[j]);
if (!ask(a))
edge[i][j] = 1;
swap(a[i], a[j]);
}
else{
swap(a[i], a[j]);
if (!ask(a))
edge[j][i] = 1;
swap(a[i], a[j]);
}
}
}
cout << "end" << endl;
for (int i = 0; i < n; i ++){
s[i] = i + 1;
for (int j = 0; j < i; j ++){
if (edge[i][j])
s[i] = min(s[i], s[j]);
}
for (int j = 0; j < i; j ++){
if (s[j] >= s[i])
s[j]++;
}
}
for (int i = 0; i < n; i ++)
cout << s[i] << " ";
cout << endl;
for (int i = 0; i < n; i ++){
b[i] = n - i;
for (int j = 0; j < i; j ++){
if (edge[j][i])
b[i] = max(b[i], b[j]);
}
for (int j = 0; j < i; j ++)
if (b[j] <= b[i])
b[j]--;
}
for (int i = 0; i < n; i ++)
cout << b[i] << " ";
cout << endl;
}
# | 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... |