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;
using ll = long long;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
int n;
cin >> n;
bool arr[n*2];
for(int i = 0;i < n*2;i++){
arr[i] = false;
}
int x;
cin >> x;
cout << x << " ";
arr[x] = true;
int l = 1;
if(x == 1) l++;
int r = 2*n-1;
if(x == r) r--;
int last = x;
for(int i = 1;i < n;i++){
cin >> x;
if(x == last){
cout << l << " " << r << " ";
arr[l] = true;
while(arr[l]){
l++;
}
arr[r] = true;
while(arr[r]){
r--;
}
}else if(x > last){
cout << x << " " << r << " ";
arr[x] = true;
arr[r] = true;
while(arr[r]){
r--;
}
}else{
cout << x << " " << l << " ";
arr[x] = true;
arr[l] = true;
while(arr[l]){
l++;
}
}
last = x;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |