编程介的小学生 2017-02-21 10:51 采纳率: 20.5%
浏览 790
已采纳

Happy Life

Problem Description
Do you know Utopia? It's a perfect world in which everyone leads a happy life.

A fairy wants to make a naive Utopia City. She studies the factors that have an impact on people's happiness and thinks that a person is happy if and only if all other persons' total "influence factor" on him (or her) is nonnegative. Each person has an influence factor on another person, which may be a positive integer or negative integer or 0. The influence factor is always symmetric, that is, if person A has an influence factor f on person B, it means that person B also has an "influence factor" f on A. So we can say the influence factor between person A and B is f without confusion. A person's influence factor on himself (or herself) is always 0. So let f(i, j) be the influence factor between person i and person j and person i's happiness(i) is well defined as follows:

Obviously there may be some persons who are not happy. Though the fairy cannot change any influence factor, she can give every person a property p(i) which is always +1 or -1. Under the fairy's magical definition, a person i's happiness(i)' is redefined as follow:

Person i feels happy if the value of happiness(i)' is nonnegative. But the fairy wonders whether she can give everyone a property to make all of them happy so that she can build her ideal naive Utopia successfully.

Since you're an ace programmer, the fairy asks you to help her to fulfill her dream. Can you help her?

Input

The input contains multiple test cases!

Each test case starts with an integer N (2 <= N <= 200), the number of persons in the city. After that there're N lines of integers and each line consists of N integers. The j-th integer of the i-th line of the matrix indicates the influence factor f(i,j) (-1000 < f(i,j) < 1000).

Proceed to the End Of File (EOF).

Output

For each test case, if the fairy fails, output a single line with "No" (without the quotations), otherwise output "Yes" (without the quotations) in the first line, followed by N lines, each line contains exactly a "+" (without the quotations) or a "-"(without the quotations) to indicate that the fairy should give the i-th person property +1 or -1 to fulfill her dream.

Sample Input

3
0 1 3
1 0 -1
3 -1 0
2
0 -10
-10 0
Sample Output

Yes

+

Yes

+

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-02-27 23:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行