#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
int main(){
ll n, k;
cin >> n >> k;
//all values between 1 and 30
//for k = 1
//smallest integer in input must have 2 consecutive of it, else insta solve
//group and ascend?
vector<pl> book[31];//book[i] stores pos of numbers i
for(ll one = 0; one < 31; one++){
book[one].push_back(make_pair(-1, -1));
book[one].push_back(make_pair(n, n));
}
ll tp, insidx = -1, insval = -1;
ll a[n];
for(ll one = 0; one < n; one++){
cin >> tp;
book[tp].push_back(make_pair(one, one));
a[one] = tp;
}
for(ll one = 0; one < 30; one++){
ll nums = book[one].size()-2;
sort(book[one].begin(), book[one].end());
if(nums%2){
insval = one;
for(ll two = 1; two <= nums; two++){
ll lb = book[one][two-1].second;
ll cl = book[one][two].first;
ll cr = book[one][two].second;
ll rb = book[one][two+1].first;
if(lb==-1 && rb==n){insidx = cr; two = nums+2; one = 31;}
else if(lb==-1){
if(rb-cr!=1){insidx = cr; two = nums+2; one = 31;}
}
else if(rb==n){
if(cl-lb!=1){insidx = cr; two = nums+2; one = 31;}
}
else if(cl-lb!=1 && rb-cr!=1){insidx = cr; two = nums+2; one = 31;}
}
}
else{
for(ll two = 1; two < nums; two+=2){
book[one+1].push_back(make_pair(book[one][two].first, book[one][two+1].second));
}
}
}
for(ll one = 0; one < n; one++){
cout << a[one] << ' ';
if(one == insidx){cout << insval << ' ';}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
541 ms |
43992 KB |
not a zalsequence |
2 |
Incorrect |
546 ms |
44348 KB |
not a zalsequence |
3 |
Correct |
584 ms |
43812 KB |
Output is correct |
4 |
Incorrect |
547 ms |
44456 KB |
not a zalsequence |
5 |
Incorrect |
546 ms |
44760 KB |
not a zalsequence |
6 |
Incorrect |
528 ms |
46144 KB |
not a zalsequence |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
535 ms |
43424 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
393 ms |
28124 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
403 ms |
27452 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
548 ms |
44472 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
525 ms |
45012 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
542 ms |
47016 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
553 ms |
44852 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
431 ms |
31492 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
320 ms |
23480 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
121 ms |
9272 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
205 ms |
15672 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |