【题目链接】:http://codeforces.com/contest/821/problem/A

【题意】



给你一个n*n的数组;

然后问你,是不是每个位置(x,y);

都能找到一个同一行的元素q和同一列的元素w;

使得q+w=a[x][y]

【题解】



O(N4)模拟



【Number Of WA】



0



【反思】



不用考虑会选到a[x][y]本身.



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 50; int a[N+10][N+10],n; void out(){
cout <<"No"<<endl;
exit(0);
} int main(){
//Open();
Close();
cin >> n;
rep1(i,1,n){
rep1(j,1,n){
cin >> a[i][j];
}
}
rep1(i,1,n){
rep1(j,1,n){
if (a[i][j]!=1){
int fi = 0;
rep1(ii,1,n)
rep1(jj,1,n)
if (a[ii][j]+a[i][jj]==a[i][j])
fi = 1;
if (!fi) out();
}
}
}
cout <<"Yes"<<endl;
return 0;
}

最新文章

  1. 用nifi executescript 生成3小时间隔字符串
  2. 【吉光片羽】MVC 导出Word的两种方式
  3. Hessian 二进制RPC协议框架
  4. 【转载】Linux下动态共享库加载时的搜索路径详解
  5. ssm开发的一点小技巧
  6. WinForm程序用使用List对象绑定DataGridView数据源
  7. c/c++常用代码--string trim
  8. Buddy system伙伴分配器实现
  9. asp.net web api的自托管模式HttpSelfHostServer可以以控制台程序或windows服务程序为宿主,不单单依赖于IIS web服务器
  10. Java web的几种异常处理 (转)
  11. 吞吐量(TPS)、QPS、并发数、响应时间(RT)概念
  12. [BZOJ1926][SDOI2010]粟粟的书架
  13. 2017/11/25 2D变换
  14. Swing组件 创建窗口应用
  15. ArcGIS中的坐标系:基本概念和常用操作(一)
  16. Delphi 7启动后提示Unable to rename delphi32.dro的解决办法
  17. LOJ.2585.[APIO2018]新家(二分 线段树 堆)
  18. mongodb集群配置分片集群
  19. 国外(英文)——WPF较好的奇葩问题解决网站
  20. 20170921xlVBA_SQL蒸发循环查询2

热门文章

  1. 你不知道的JavaScript演示代码Github地址
  2. 监控RMAN操作进度的脚本
  3. 总结Ajax的一些细节
  4. Hadoop-2.4.1 ubuntu集群安装配置教程
  5. python学习笔记:第八天
  6. SPOJ 962 Intergalactic Map
  7. ubuntu下安装宋体simsun
  8. Jquery-基础知识点
  9. COGS——T 803. [USACO Hol10] 政党 || 1776: [Usaco2010 Hol]cowpol 奶牛政坛
  10. 【Hibernate学习】 ——ORM(二)