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
+
-

暴力,为什么不会出现No的情况呢?

#include <stdio.h>
#define MAXN 220 int n;
int g[MAXN][MAXN];
int ans[MAXN]; int main(){
int i,j;
while( scanf("%d",&n)!=EOF ){
for(i=1; i<=n; i++){
for(j=1; j<=n; j++){
scanf("%d" ,&g[i][j]);
}
ans[i]=1;
}
int index=1;
while(1){
if(index==n+1){
break;
}
int sum=0;
for(i=1; i<=n; i++){
sum+=ans[i]*g[index][i];
}
if(sum*ans[index]<0){
ans[index]*=-1;
index=1;
}
else index++;
}
puts("Yes");
for(int i=1; i<=n; i++){
if(ans[i]<0)
puts("-");
else
puts("+");
}
}
return 0;
}

最新文章

  1. C#中考虑为大对象使用弱引用
  2. xml、文件操作功能类
  3. AngularJs+bootstrap搭载前台框架——准备工作
  4. MVC项目初次发布到IIS可能会遇到的问题
  5. BeanFactory学习
  6. J2EE (十) 简洁的JSTL、EL
  7. 学习selenium所须要具备的技术
  8. (转)Java线程:线程的同步与锁
  9. jquery的动画学习--jquery权威指南
  10. [POI 2004]ZAW
  11. 蓝书例题之UVa 10253 Series-Parallel Networks
  12. Spirng boot maven多模块打包不踩坑
  13. 学习 Spring (六) 自动装配
  14. Jmeter 批量执行脚本之-----------Ant
  15. Kibana学习笔记——安装和使用
  16. 准备用有人云平台和tlink.io云平台和电脑做云转发
  17. QT5 - 数据库、QMYSQL driver not loaded
  18. ElasticStack系列之十二 &amp; 搜索结果研究
  19. Android Path Time ScrollBar(Path 时间轴)
  20. npm下载缓慢解决方法

热门文章

  1. solr&amp;lucene3.6.0源码解析(二)
  2. RPM管理,计划任务与性能监控
  3. RzToolbutton用法
  4. MVC4 基于 Unity Ioc 框架的 ControllerFactory
  5. MongoDB高级知识-易使用
  6. RHEL因为selinux设置失误,无法重启问题。(centos适用)
  7. django学习篇
  8. 《Think in Java》17~18
  9. “全栈2019”Java第四十四章:继承
  10. myeclipse关于svn更新报错:OPTIONS of &#39;/svn/Xxx&#39;: 403 Forbidden