You are on page 1of 6

...

John Nash: Yes, it’s all good so far, but keep this in mind:
best result comes from everyone in a group doing
what's best for themselves and the group!

New in Level 4: Executing Trades with Friends


All the econs take turns trading in the order of their ids. (The econ with the id 1 is the first one
to execute a trade, then econ 2, etc.) Trades are no longer independent from each other,
meaning after each trade, the content of the two econs basket will change in accordance to
the trade. Each econ will always execute the trade that will benefit them the most in the
current moment. Every trade still has to benefit both econs just like in the last level. If an econ
has no beneficial trade available to them, it will skip its turn. Print ‘NO TRADE’ in that case. The
econs will trade until no one can do a beneficial trade anymore. It is possible for one econ to
have multiples of a sweet as a result of trading.

Econs will now only initiate a trade with another econ that it considers its friend. An econ will
still participate in a trade with another econ that it does not consider its friend.

Output a sequence of valid trades where every econ always executes the trade that is most
beneficial to them at the moment where in the end no econ has a beneficial trade available
anymore. When two trades are equally beneficial, the rules from last level apply. The last line in
the output should be the last trade that is executed.
The output format is identical to last level

Input Output

N ecoId1 sweetTypeId1 ecoId2 sweetTypeId2


ecoId1 type1 type2 . . . typeT (line is repeated N times where N is the
(line is repeated N times) number of econs)
T
Format
type1 value1 value2 . . . valueN
(line is repeated T times)
ecoId friendId1 friendId2 . . . friendIdN
(line is repeated N times)

N (int): number of econs ecoId1 (int): id of the eco that is executing


ecoId (int): id of the econ the trade
sweetTypeId (int): the id of the sweet type sweetTypeId1 (int): id of the sweet that eco1
T (int): number of sweet types is trading a away
Types
value (int): value of that sweet to the econ with the ecoId2 (int): the id of the econ that eco1
is trading with
corresponding id
sweetTypeId2 (int): id of the sweet that eco1
friendId (int): id of a friend is receiving
Input Output

6 1 6 4 2
1 5 6 8 3 1 2 NO TRADE
2 4 3 6 6 3
3 1 3 7 8 5 6 4 7 3 5
4 2 8 7 5 5 1 2
5 8 5 1 NO TRADE
6 6 3 4 1 7 2 8 5 1 1 4 5
8 NO TRADE
1 2 2 10 5 4 7 3 7 5 1
2 8 6 7 5 9 4 NO TRADE
3 9 3 10 4 1 1 5 8 3 7
Example
4 10 9 8 1 4 5
5 10 5 6 3 1 3
6 1 9 4 7 3 3
7 3 6 9 2 10 7
8 8 2 10 3 9 7
1 4
2
3 5 6
4 3
5 1 3 4
6 2
GOOD LUCK

You might also like