QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#14511. 不許偷吃

统计

在一次訓練結束後,小豬與兩位隊友以及一名教練共四人相約去吃飯。他們選擇了避風塘餐廳,並點了許多點心,如蝦餃、紅米腸、乳鴿等。

他們總共點了 $n$ 份菜,第 $i$ 道菜包含 $a_i$ 個點心。為了實現均分,所有點心的總數一定是 4 的倍數。然而,由於上菜速度較慢,且每道菜的點心數不一定都是 4 的倍數,因此點心往往分批上桌。

每當上一道菜後,如果餐桌上的點心總數不少於 4,四人就會各自吃掉一個點心,直到剩下的點心不足 4 個為止。由於上菜緩慢,在新的點心上桌之前,桌上的點心數始終小於 4。

但是,小豬喜歡偷吃!為了不被發現,小豬只會在餐桌上恰好剩下 1 個點心時,迅速將其吃掉。小豬偷吃後,大家會誤以為餐廳份量不足,從而投訴餐廳。而你,作為避風塘的經理,雖然無法加快上菜速度,但可以調整每道菜的上菜順序。

現在,請你判斷,是否存在一種上菜順序,使得小豬沒有機會偷吃點心,從而避免顧客投訴餐廳呢?

輸入格式

本題有多組數據。第一行一個整數 $T$ ($1 \le T \le 10^4$),表示數據組數。

對於每組數據: 第一行一個整數 $n$ ($1 \le n \le 10^5$) 表示點的菜品數。 接下來一行 $n$ 個整數 $a_1, \dots, a_n$ ($1 \le a_i \le 100$)。

保證 $\sum_{i=1}^n a_i$ 是 4 的倍數,保證 $T$ 組數據中 $n$ 的和不超過 $10^5$。

輸出格式

對於每組數據: 如果無論用什麼順序小豬都會偷吃,輸出 -1。 否則,輸出一個排列 $p_1, \dots, p_n$,表示上菜的順序。第 $i$ 次上第 $p_i$ 道菜。 如果有多種答案,輸出任意一種答案即可。

範例

輸入 1

3
4
4 6 3 3
4
1 3 3 1
4
1 1 1 1

輸出 1

3 1 4 2
2 3 4 1
-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.