Codeforces Round #420 (Div. 2) - A
题目链接:http://codeforces.com/contest/821/problem/A
题意:给定一个n*n的矩阵。 问你这个矩阵是否满足矩阵里的元素除了1以外,其他元素都可以在该元素的行和列分别找一个数然后相加等于它自身。
思路:按照题意暴力判断即可。
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<time.h>
#include<cmath>
using namespace std;
typedef long long int LL;
const LL INF = ;
const int MAXN = + ;
int val[MAXN][MAXN];
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
// int start = clock();
int n;
while (~scanf("%d",&n)){
for (int i = ; i < n; i++){
for (int j = ; j < n; j++){
scanf("%d", &val[i][j]);
}
}
bool flag = true;
for (int i = ; i < n&&flag; i++){
for (int j = ; j < n&&flag; j++){
if (val[i][j] == ){
continue;
}
bool k = false;
for (int xi = ; xi < n; xi++){
for (int xj = ; xj < n; xj++){
if (val[i][j] == val[i][xj] + val[xi][j]){
k = true;
break;
}
}
}
if (k == false){
flag = false;
}
}
}
printf(flag ? "Yes\n" : "No\n");
}
//#ifdef LOCAL_TIME
// cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
return ;
}
Codeforces Round #420 (Div. 2) - A的更多相关文章
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- Codeforces Round #420 (Div. 2) - C
题目链接:http://codeforces.com/contest/821/problem/C 题意:起初有一个栈,给定2*n个命令,其中n个命令是往栈加入元素,另外n个命令是从栈中取出元素.你可以 ...
- Codeforces Round #420 (Div. 2) - E
题目链接:http://codeforces.com/contest/821/problem/E 题意:起初在(0,0),现在要求走到(k,0),问你存在多少种走法. 其中有n条线段,每条线段为(a, ...
- Codeforces Round #420 (Div. 2) - B
题目链接:http://codeforces.com/contest/821/problem/B 题意:二维每个整点坐标(x,y)拥有的香蕉数量为x+y,现在给你一个直线方程的m和b参数,让你找一个位 ...
- Codeforces Round #420 (Div. 2)
/*************************************************************************************************** ...
- Codeforces Round #420 (Div. 2) A,B,C
A. Okabe and Future Gadget Laboratory time limit per test 2 seconds memory limit per test 256 megaby ...
- Codeforces Round #420 (Div. 2) E. Okabe and El Psy Kongroo 矩阵快速幂优化dp
E. Okabe and El Psy Kongroo time limit per test 2 seconds memory limit per test 256 megabytes input ...
随机推荐
- RedisTemplate 事务处理方法 watch multi exec 的使用
@Autowired RedisTemplate<String,String> redisTemplate; redisTemplate.execute(new SessionCallba ...
- redis不重启之rdb数据切换到aof数据
温馨提示: 要实现不重启从rdb切换到aof,redis的版本必须要在2.2以上. [root@pyyuc /data ::]#redis-server -v Redis server v= sha= ...
- Test 6.29 T1 预算方案
问题描述 "我需要你为我制订一个购物的方案.我将要为我的宫殿增置一些家具.有n 种备选家具,家具有主件和附件之分.在购买某个主件的附件之前,我必须先购买其对应的主件.某一主件的附件不会是另一 ...
- hdu 1693 : Eat the Trees 【插头dp 入门】
题目链接 题意: 给出一个n*m大小的01矩阵,在其中画线连成封闭图形,其中对每一个值为1的方格,线要恰好穿入穿出共两次,对每一个值为0的方格,所画线不能经过. 参考资料: <基于连通性状态压缩 ...
- 在一个div上增加遮罩
有一个需求是给一个视频增加遮罩 我研究了下 抽象出来就是给一个div增加遮罩 原理是:最外层的div使用relative定位 然后里面放两个子div 一个是不被遮的 另一个是遮罩(用abs ...
- basic deepwalk
Get to know How deepwalk works by this project. Two steps: 1. gen the graph, and gen the corpus on t ...
- iOS多媒体总结&进入后台播放音乐
1. 播放mp3需要导入框架,AVFoundation支持音频文件(.caf..aif..wav..wmv和.mp3)的播放. #import <AVFoundation/AVFoundatio ...
- // 62.是否有利润奖--lrj private boolean isProfitsAward; // 63.利润奖--lrj_price private String profitsAward;
// 62.是否有利润奖--lrj private boolean isProfitsAward; // 63.利润奖--lrj_price private String profitsAward; ...
- python中的方法使用
#Python其实有3个方法,即静态方法(staticmethod),类方法(classmethod)和实例方法,如下: class Foo: def bar(self): # cls 是当前对象的实 ...
- iOS打印各种类型数据
整型占位符说明 : %d : 十进制整数, 正数无符号, 负数有 “-” 符号; %o : 八进制无符号整数, 没有 0 前缀; %x : 十六进制无符号整数, 没有 0x 前缀; %u : 十进制无 ...