#include <bits/stdc++.h>
using namespace std;
vector<int>vv;
int a[100009*2+2];
int v[100009*2+2];
int get (int x)
{
while (v[x]==1)
{
x--;
}
return x;
}
int get1 (int x)
{
while (v[x]==1)
{
x++;
}
return x;
}
int main()
{
int l=1;
int n;cin>>n;
int r=(2*n)-1;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if (i==1)
{
v[a[i]]=1;
vv.push_back(a[i]);
continue;
}
if (v[a[i]]==1)
{
if (a[i]>a[i-1])
{
r=get (r);
v[r]=1;
vv.push_back(r);
r=get (r);
v[r]=1;
vv.push_back(r);
}
else {
l=get1 (l);
v[l]=1;
vv.push_back(l);
l=get1 (l);
v[l]=1;
vv.push_back(l);
}
}
else {
if (a[i]>a[i-1])
{
v[a[i]]=1;
r=get (r);
v[r]=1;
vv.push_back(a[i]);
vv.push_back(r);
}
else {
v[a[i]]=1;
v[l]=1;
l=get1 (l);
vv.push_back(a[i]);
vv.push_back(l);
}
}
}
for(auto pp:vv)cout<<pp<<" ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
256 KB |
Not a permutation |
3 |
Incorrect |
2 ms |
248 KB |
Not a permutation |
4 |
Incorrect |
2 ms |
256 KB |
Not a permutation |
5 |
Incorrect |
2 ms |
256 KB |
Not a permutation |
6 |
Incorrect |
0 ms |
256 KB |
Integer 120 violates the range [1, 119] |
7 |
Incorrect |
2 ms |
256 KB |
Not a permutation |
8 |
Incorrect |
2 ms |
256 KB |
Not a permutation |
9 |
Incorrect |
2 ms |
256 KB |
Not a permutation |
10 |
Incorrect |
2 ms |
376 KB |
Not a permutation |
11 |
Incorrect |
2 ms |
376 KB |
Not a permutation |
12 |
Incorrect |
2 ms |
376 KB |
Not a permutation |
13 |
Incorrect |
2 ms |
376 KB |
Not a permutation |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Not a permutation |
2 |
Incorrect |
4 ms |
504 KB |
Not a permutation |
3 |
Incorrect |
6 ms |
632 KB |
Not a permutation |
4 |
Incorrect |
10 ms |
1016 KB |
Not a permutation |
5 |
Incorrect |
18 ms |
1652 KB |
Not a permutation |
6 |
Incorrect |
33 ms |
2800 KB |
Not a permutation |
7 |
Incorrect |
57 ms |
4332 KB |
Not a permutation |