루미 알고리즘

#1542골드Hockey Match

PO 2022 온라인 예선코딩출제 Johan Sannemo, Abdullah Zaghmout영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

Malin loves watching ice hockey. Unfortunately, she had too much homework to do last night and couldn't watch the live broadcast of her favorite team's latest game, so now she is curious about what happened during the match.

Usually, she checks Kvällspappret's sports pages to find out, but unfortunately, a large part of their website is broken (they need better programmers, as good as PO participants) and only a part of the statistics can be read. Malin is primarily interested in three different questions for each team: the number of goals they scored, the number of shots their goalkeeper saved, and the total number of shots they took on the opponent's goal. Given some of this statistics for each team, reconstruct as much of the statistics as possible.

Input

The first line contains three integers: the number of saves made by the first team's goalkeeper, the number of goals scored by the first team, and the number of shots the first team took on the opponent's goal. The second line contains the corresponding information for the second team.

All known numbers in the statistics are between 0 and 10^9. If a number in the statistics is missing, it is replaced with -1.

It is guaranteed that there is at least one way to replace all -1 with numbers so that the resulting statistics are correct.

Output

Print the statistics for the two teams in the same format as the input. All missing statistics that can be uniquely determined from the other numbers should be printed instead of -1. If it is not possible to uniquely determine a certain number, print -1.

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

GroupPointsConstraints
130All numbers can be reconstructed.
220All numbers in the original statistics were at most 5.
350No additional constraints.

Explanation of Example Case 1

Since the first team had a total of 3 shots on goal and the second team had 2 saves, they must have conceded the last shot, resulting in 1 goal. Since the first team made 1 save but the second team scored 4 goals, the second team must have made a total of 5 shots on goal.

This case could occur in all test groups.

예제

예제 1

입력
1 -1 3
2 4 -1
출력
1 1 3
2 4 5

예제 2

입력
-1 -1 1
1 -1 0
출력
0 0 1
1 0 0

예제 3

입력
-1 -1 -1
-1 -1 -1
출력
-1 -1 -1
-1 -1 -1

출처 표기

출처: Programmeringsolympiaden 2022년 온라인 예선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.