#P10672. 【MX-S1-T1】 壁垒

    ID: 12131 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>搜索Special JudgeO2优化排列组合构造梦熊比赛

【MX-S1-T1】 壁垒

Background

Original link: https://oier.team/problems/S1A

Problem Description

You are given a sequence aa of length nn consisting only of positive integers, and it is guaranteed that nn is even. You need to reorder aa so that, for every prefix of aa whose length is even, the number of distinct values that have appeared is even, or determine that no such reordering exists。

If there are multiple reorderings that satisfy the condition, you may output any one of them。

Input Format

The first line contains one positive integer nn, and it is guaranteed that nn is even。

The second line contains nn positive integers describing the sequence aa

Output Format

If there is no solution, output 1-1. Otherwise, output one line with nn integers describing the reordered sequence aa

This problem uses a custom checker to verify whether your output is correct. If there are multiple reorderings that satisfy the condition, you may output any one of them。

6
2 3 3 4 1 1
1 3 3 1 2 4
2
1 1
-1

Hint

Sample Explanation 1

The sets {1,3}\{1,3\}, {1,3,3,1}\{1,3,3,1\}, and {1,3,3,1,2,4}\{1,3,3,1,2,4\} all have an even number of distinct values。

Constraints

This problem uses bundled subtasks.

For 100%100\% of the testdata, 2n1052\le n\le 10^5, 1ain1\le a_i\le n, and it is guaranteed that nn is even。

Subtask ID nn\le aia_i\le Points
11 1010 nn 2020
22 2020
33 10510^5 22
44 1010
55 nn

Translated by ChatGPT 5