X Olympiad in Informatics 2002/2003
|
Problem: Mastermind II
|
Author: Zbigniew Czech
|
We shall consider sequences that meet the following conditions:
When two codes are given we estimate their compatibility giving two numbers. The first one (column A in the example) is the sum of those digits that occur in both codes and appear on the same positions in both sequences, whilst the second number (column B) is the sum of those digits that occur in both codes but appear on different positions.
We are given c codes and their compatibility estimations with some unknown code. One should find and present the unknown code. Sample data and a result for c = 3 are presented below.
A | B | codes | ||
---|---|---|---|---|
4 | 0 | 4 | 9 | 7 |
0 | 10 | 6 | 7 | 4 |
0 | 5 | 9 | 4 | 1 |
unknown code | 4 | 1 | 6 |
Your program should write to the standard output. There should be c different digits from the range of 1-9 forming the code to be found, separated by single spaces.
You may assume that for the test data there is at least one solution. If for the input data there exist many satisfying codes, your program should write out only one of them (arbitrary).
3 4 0 4 9 7 0 10 6 7 4 0 5 9 4 1a correct answer is in the following output:
4 1 6