Educational Codeforces Round 138中A. Cowardly Rooks
Codeforces比赛记录
A. Cowardly Rooks
题目链接:
一、A. Cowardly Rooks
题目意思:
这个题目的意思是一个棋盘上放了一些棋子,这些棋子如果在同一行或者同一列那么就会互相进攻。问:是否有可能移动一个车(你可以选择移动哪一个)到不同的单元,这样就不会有两个车互相攻击了?如果没有其他车站在它的路径上,车可以移动到它所在行或列的任何单元格。
上思路:
其实特别简单:只有n < m即可。
n是行数和列数,m是棋子的个数,只有棋子的个数小于列数/行数,就证明它可以移动一下,然后不发生攻击现象的。
为什么?因为题目规定了,一开始棋子是不发生攻击的。
题目在输入描述的原话。
No two rooks occupy the same cell. No two rooks attack each other.
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define db double
#define sc scanf
#define pf printf
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int n, m, T;
int main() {
cin>>T;
while(T--) {
cin>>n>>m;
int a,b;
for(int i = 0; i < m; ++i) {
cin>>a>>b;
}
if(n <= m) {
cout<<"NO\n";
}
else {
cout<<"YES\n";
}
}
}
总结
阅读理解啊!!!少看了一句导致没有做出来。