Logo
(追記) (追記ここまで)

23131번 - Permute 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB2000.000%

문제

Given a decimal integer $s,ドル you need to permute the digits of $s$ to obtain a number divisible by 7ドル,ドル or determine that it is impossible.

Leading zeroes in decimal integers are allowed in this problem.

입력

The first line contains an integer $T,ドル the number of test cases (1ドル \le T \le 10^5$). The descriptions of test cases follow.

A test case contains exactly one line with ten integers $c_0, c_1 \dots c_9,ドル where $c_i$ is the number of digits $i$ in $s$ (0ドル \le c_i \le 10^9,ドル $\sum c_i > 0$).

출력

For each test case, if it is possible, print the permuted number formatted according to the rules below. Otherwise, print $-1$.

Because the number $s$ can be very large, you have to print the permuted number in segments, from left to right. First, print a line containing an integer $k,ドル the number of segments (1ドル \le k \le 100$). Then print $k$ more lines, the $i$-th of which will contain two integers $r_i$ and $x_i,ドル indicating that the $i$-th segment of digits in the permuted number consists of $r_i$ repetitions of the digit $x_i$ ($r_i \ge 0,ドル 0ドル \le x_i \le 9$).

It can be shown that, if an answer exists, then there also exists an answer which can be represented under the above constraints. If there are several possible solutions, print any one of them.

제한

예제 입력 1

3
0 1 0 0 1 0 0 0 0 0
0 2 0 0 0 0 1 0 0 1
0 1000000000 0 0 0 0 0 0 0 0

예제 출력 1

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

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 4: 2021 Shanghai ICPC Camp Onsite 1 by PKU C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /