A. 美丽数(beauty)

    Type: Default 1000ms 256MiB

美丽数(beauty)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

小B 对数字有着独到的见解,他认为一个数是美丽数当且仅当这个数的相邻两位都不相同。

例如 1234512121是美丽数,而12332111不是美丽数。

现在小B想知道,对于所有满足以下条件的数中,最小的那个数是什么?如果不存在这样的美丽数,则输出 -1

  • 对于 i(0i9)i(0\le i\le 9),这个数中是 ii 的位数一共有 aia_i 个。
  • 这个数不能有前导 00 ,即 012 是不合法的。

有多组测试点,每组测试点现在给你 a0a9a_0\sim a_9 ,请你回答小B的问题。

输入格式

第一行包含一个整数 TT

接下来 TT 行,每行 1010 个整数,a0a9a_0\sim a_9 ,含义如题。

输出格式

输出 TT ,每行一个整数,表示答案。

5
5 0 0 0 0 0 0 0 0 5
6 0 0 0 0 0 0 0 0 5
0 1 0 2 0 0 0 0 0 0
3 0 0 0 2 0 0 1 0 0 
0 1 2 3 4 5 6 7 8 9
9090909090
-1
313
404070
123234345454565656767676787897979898989898989

数据范围

对于 100%100\% 的数据,保证:T10,1n,ai105T\le 10,1 \leq n,a_i\le 10^5,其中 n=i=09ain=\sum_{i=0}^9a_i

测试点编号 数据范围 特殊性质
121\sim 2 n10n\le 10
343\sim 4 n103n\le 10^3
565\sim 6 无限制 A\text{A}
787\sim 8 B\text{B}
9109\sim 10

A:\text{A}: 保证最多只有 22ai>0a_i>0

B:\text{B}: 保证最多只有 33ai>0a_i>0

0705

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2025-7-5 8:30
End at
2025-7-5 12:00
Duration
3.5 hour(s)
Host
Partic.
32