您的位置:首页 > 其它

贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet

2015-06-06 17:24 441 查看
题目传送门

 /*
贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAXN = 11;
const int INF = 0x3f3f3f3f;
char s[MAXN][MAXN];

int main(void)        //Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
{
int t;    scanf ("%d", &t);
while (t--)
{
char ch;    int x1, y1, x2, y2;    bool ok = false;

for (int i=1; i<=8; ++i)    scanf ("%s", s[i] + 1);
for (int i=1; i<=8; ++i)
{
for (int j=1; j<=8; ++j)
{
if (!ok && s[i][j] == 'K')    {x1 = i;    y1 = j;    ok = true;}
if (ok && s[i][j] == 'K')    {x2 = i;    y2 = j;}
}
}

if ((x2 - x1) % 4 == 0 && (y2 - y1) % 4 == 0)    puts ("YES");
else    puts ("NO");
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: