0
点赞
收藏
分享

微信扫一扫

B. Symmetric Matrix(思维) Codeforces Round #674 (Div. 3)

原题链接: ​​https://codeforces.com/contest/1426/problem/B​​

B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_对称矩阵
测试样例

input
6
3 4
1 2
5 6
5 7
7 4
8 9
9 8
2 5
1 1
1 1
2 2
2 2
1 100
10 10
10 10
1 2
4 5
8 4
2 2
1 1
1 1
1 2
3 4
1 2
1 1
1 1
output
YES
NO
YES
NO
YES
YES

Note

The first test case of the input has three types of tiles, they are shown on the picture below.
B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_#define_02
Masha can construct, for example, the following square of size 4×4 which is a symmetric matrix:
B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_#define_03

题意: 给你B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_ios_04个类型的B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_ios_05的正方形格,你需要去构建一个B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_ios_06的对称矩阵,问你是否可行。

解题思路: 我们要抓住题中的关键信息:基础格为B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_对称矩阵_07的,所以我们不可能构建一个B. Symmetric Matrix(思维)  Codeforces Round #674 (Div. 3)_ios_08为奇数的对称矩阵。这里即可特判。 那么还有哪些信息呢?就是正方形格不能被旋转放置以及正方形格的数量不限,可以任意使用。OK,我们来看这个样例。我们发现,控制这个对称的只有单元格的右上和左下。因为如果我们使用同一个单元格的话,左上和右下是与别的单元格相同的,不关乎内部构造(仔细理解这段话,仔细看一下样例。)。 故,此题易解。

AC代码

/*

*
*/
#include<bits/stdc++.h> //POJ不支持

#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int inf = 0x3f3f3f3f;//无穷大
const int maxn = 1e5;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割线,以上为自定义代码模板***************************************//

int t,n,m;
int main(){
//freopen("in.txt", "r", stdin);//提交的时候要注释掉
IOS;
while(cin>>t){
while(t--){
cin>>n>>m;
//我只要有右上等于左下就好。
int a,b,c,d;
bool flag=false;
rep(i,0,n-1){
cin>>a>>b>>c>>d;
if(b==c){
flag=true;
}
}
if(m%2){
cout<<"NO"<<endl;
continue;
}
if(flag){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
}
return 0;
}


举报

相关推荐

0 条评论