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

31176번 - Puzzle in Inazuma 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB248833.333%

문제

Every traveler knows that they'll be rewarded with a treasure box after solving the puzzles in Inazuma, but few know that these puzzles are designed by Yae Miko, the Guuji of the Grand Narukami Shrine, to test whether the traveler is strong enough to save her friend Raiden Shogun and people of Inazuma.

Grand Narukami Shrine

After a traveler passes the test Yae will have to reset the puzzles to the initial state. But this time she has some troubles and even doubts that whether some of them are already broken.

Yae's puzzle can be considered as a weighted undirected complete graph $G$ before resetting. We also denote the initial state as another weighted undirected complete graph $H$. Both $G$ and $H$ have exactly $n$ vertices, and these vertices are labeled from 1ドル$ to $n$.

To reset graph $G$ to $H$ Yae can perform the following operation any number of times:

  • First select four distinct vertices $a,ドル $b,ドル $c,ドル $d$ and an integer $x$. Note that she can select a different set of $a,ドル $b,ドル $c,ドル $d$ and $x$ each time.
  • Let $(i, j)$ be the edge between vertices $i$ and $j$. Increase the weight of $(a, b),ドル $(a, c)$ and $(a, d)$ by $x$ and also decrease the weight of $(b, c),ドル $(b, d)$ and $(c, d)$ by $x$.

Please help Yae determine whether she can change graph $G$ to graph $H$. If yes you also shall tell her the detailed steps.

입력

There is only one test case in each test file.

The first line of the input contains an integer $n$ (4ドル \leq n \leq 100$) indicating the number of vertices in graph $G$ and $H$.

For the following $(n - 1)$ lines, the $i$-th line contains $(n - i)$ integers $w_{i, i + 1}, w_{i, i + 2}, \cdots, w_{i, n}$ ($-100 \le w_{i, j} \le 100$) where $w_{i, j}$ indicates the weight of the edge connecting vertices $i$ and $j$ in graph $G$.

For the following $(n - 1)$ lines, the $i$-th line contains $(n - i)$ integers $v_{i, i + 1}, v_{i, i + 2}, \cdots, v_{i, n}$ ($-100 \le v_{i, j} \le 100$) where $v_{i, j}$ indicates the weight of the edge connecting vertices $i$ and $j$ in graph $H$.

출력

If Yae cannot change $G$ to $H$ output "-1" (without quotes).

Otherwise first output an integer $m$ (0ドル \le m \le 10^5$) in one line indicating the number of operations Yae needs.

For the following $m$ lines, output five integers $a_i,ドル $b_i,ドル $c_i,ドル $d_i$ and $x_i$ in the $i$-th line separated by a space, indicating that for the $i$-th operation Yae choose vertices $a_i,ドル $b_i,ドル $c_i,ドル $d_i$ and integer $x_i$. Note that $a_i,ドル $b_i,ドル $c_i,ドル $d_i$ must be distinct and $-10^9 \le x_i \le 10^9$.

It can be proved that if graph $G$ can be changed to graph $H$ there exists a solution with no more than 10ドル^5$ operations.

Note that you don't have to minimize $m$. If there are multiple solutions, output any of them.

제한

예제 입력 1

4
0 1 1
0 0
1
1 0 0
1 1
0

예제 출력 1

1
2 1 3 4 1

예제 입력 2

4
3 3 3
0 0
0
0 0 0
3 3
3

예제 출력 2

1
1 2 3 4 -3

예제 입력 3

5
-12 15 -12 1
37 14 7
7 9
-11
12 5 1 13
-1 -4 -7
-5 -9
18

예제 출력 3

-1

힌트

출처

Contest > Open Cup > 2021/2022 Season > Stage 9: Grand Prix of Nanjing B번

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

출처

대학교 대회

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

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