이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
bool ask(){
cout << "query ";
for(int i = 1; i <= n; ++i) cout << a[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 = i + 1; j <= n; ++j){
swap(a[i], a[j]);
bool ok = ask();
swap(a[i], a[j]);
if(!ok && abs(a[i] - a[j]) < wr1 - wr2) wr1 = max(a[i], a[j]), wr2 = min(a[i], a[j]);
}
}
cout << "end\n";
int emp = 0;
for(int i = 1; i <= n; ++i){
if(!emp && a[i] == wr1){
emp = i;
cout << i + 1 << " ";
}
else if(a[i] == wr2){
if(emp) cout << emp << " ";
else cout << i << endl;
emp = -1;
}
else cout << i << " ";
}
cout << endl;
emp = 0;
for(int i = 1; i <= n; ++i){
if(!emp && a[i] == wr2){
emp = i;
cout << n - i << " ";;
}
else if(a[i] == wr1){
if(emp) cout << emp << " ";
else cout << n - i + 1 << " ";
emp = -1;
}
else cout << n - i + 1 << " ";
}
cout << endl;
return 0;
}
| # | 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... |