设为首页 加入收藏

TOP

Codeforces Round #270 A~D(三)
2015-07-20 17:34:28 来源: 作者: 【 】 浏览:8
Tags:Codeforces Round #270
ut
3
0 1 1
1 0 1
1 1 0
output
NO
input
2
0 0
0 0
output
NO
Note

In the first example, the required tree exists. It has one edge between nodes 1 and 2 with weight 2, another edge between nodes 1 and 3 with weight 7.

In the second example, it is impossible because d1,?1 should be 0, but it is 1.

In the third example, it is impossible because d1,?2 should equal d2,?1.


#include 
          
           
#include 
           
             #include 
            
              #include 
             
               using namespace std; typedef long long int LL; const int maxn=2222; int n; LL d[maxn][maxn]; int main() { scanf("%d",&n); bool flag=true; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { scanf("%I64d",&d[i][j]); if(i==j&&d[i][j]) flag=false; } } for(int i=1;i<=n&&flag;i++) for(int j=1;j<=n&&flag;j++) { if(d[i][j]!=d[j][i]) flag=false; if(i!=j&&d[i][j]==0) flag=false; } if(flag==false) { puts("NO"); return 0; } for(int i=1;i<=n&&flag;i++) { LL MINI=(1LL<<62),pos=-1; for(int j=1;j<=n;j++) { if(d[i][j]
              
               




首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇nginx 学习八 高级数据结构之基数.. 下一篇[思路题] spoj 11354 Amusing num..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)
·Redis配置中`require (2025-12-26 03:18:58)
·Asus Armoury Crate (2025-12-26 02:52:33)
·WindowsFX (LinuxFX) (2025-12-26 02:52:30)