【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
【题目链接】: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;
}
【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory的更多相关文章
- 【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 #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
- 【Codeforces Round #423 (Div. 2) A】Restaurant Tables
[Link]:http://codeforces.com/contest/828/problem/A [Description] 有n个组按照时间顺序来餐馆; 每个组由一个人或两个人组成; 每当有一个 ...
- 【Codeforces Round #422 (Div. 2) D】My pretty girl Noora
[题目链接]:http://codeforces.com/contest/822/problem/D [题意] 有n个人参加选美比赛; 要求把这n个人分成若干个相同大小的组; 每个组内的人数是相同的; ...
- 【Codeforces Round #422 (Div. 2) C】Hacker, pack your bags!(二分写法)
[题目链接]:http://codeforces.com/contest/822/problem/C [题意] 有n个旅行计划, 每个旅行计划以开始日期li,结束日期ri,以及花费金钱costi描述; ...
- 【Codeforces Round #422 (Div. 2) B】Crossword solving
[题目链接]:http://codeforces.com/contest/822/problem/B [题意] 让你用s去匹配t,问你最少需要修改s中的多少个字符; 才能在t中匹配到s; [题解] O ...
随机推荐
- 【参考】Linux下的Memcache安装
服务器端主要是安装memcache服务器端.下载:http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz另外,Memcache用到了lib ...
- swift语言点评三 - Basic Operators
1.Tuples are compared from left to right, one value at a time, until the comparison finds two values ...
- Converting Legacy Chrome IPC To Mojo
Converting Legacy Chrome IPC To Mojo Looking for Mojo Documentation? Contents Overview Deciding What ...
- 虚拟机创建后该如何获取IP地址并访问互联网实用教程
之前在做项目的时候主机IP地址.网关.DNS.子网掩码等都是公司或者对方直接给提供的,但是如果我们自己想搭建一台虚拟机或者一台集群的话,手头又没有IP地址,该肿么办呢? 白慌,这里介绍一个小技巧, ...
- oralce模糊查询之含有通配符
oracle中通配符有 '_'和'%'当like '_ww%'时,会把'_'和'%'当作通配符使用导致查不出含有'_'和'%'的数据.这时用到转译字符 like '\_ww\%' escape '\ ...
- 4.有关日期格式属性改动常识,v$nls_parameters,between and,查询指定部门的员工信息,in和null,like模糊查询,order by后面能够跟:列名、表达式、别名、序号
1 有关日期格式属性改动常识 NLS_DATE_FORMAT DD-MON-RR select sysdate from dual; NLS_CURRENCY ...
- LightOJ - 1132 Summing up Powers 矩阵高速幂
题目大意:求(1^K + 2^K + 3K + - + N^K) % 2^32 解题思路: 借用别人的图 能够先打表,求出Cnm,用杨辉三角能够高速得到 #include<cstdio> ...
- 与Greenplum度过的三个星期
5月4日-5月24日.断断续续折腾了三个星期的Greenplum,总算告一段落了:扩容,发现扩不成容.仅仅好升级.升级,发现一堆错误,仅仅好暂停修复数据库:修好了,继续升级.升完级,发现错误.修啊修啊 ...
- YII显示sql进行调试
进行插入測试: 一个简单控制器: function actionJia(){ $goods_model = new Goods(); //进行加入有别于查询不能使用以下这样的方式 // $goods_ ...
- 编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)
首先下载得到boost的最新版(目前最新版是1.63) 下载地址: http://www.boost.org 也可以从这里直接下载 http://download.csdn.net/detail/ ...