A. Two Semiknights Meet

  题目大意:有一个8x8的棋盘,上面放有两个骑士,骑士以“田字”的方式走。每个方格都被定义为good或者bad,问骑士能否在good的格子中相遇?

  由于骑士最初位于good的格子中,并且骑士可以按原路返回,所以只需判断骑士是否能够相遇就行了(相遇后可以返回任意一个骑士的初始位置)。根据骑士的移动特性,两个骑士位置的行和列之差应该为4的倍数。

  自己开始的时候,还试图计算相遇位置,然后bfs逐个验证,想麻烦了...

 #include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef pair<int, int> pii; const int N = ;
int m[N][N];
pii knight[]; bool judge()
{
int row_diff = abs(knight[].first - knight[].first);
int col_diff = abs(knight[].second - knight[].second);
if (row_diff % != || col_diff % != ) return false;
return true;
} int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int T;
scanf("%d", &T);
getchar();
while (T--)
{
// read data
char s[];
int p = ;
memset(m, , sizeof(m));
for (int i = ; i < ; ++i)
{
gets(s);
for (int j = ; j < ; ++j)
{
if (s[j] == '#') m[i][j] = ;
else if (s[j] == 'K')
{
m[i][j] = ;
knight[p++] = make_pair(i,j);
}
}
}
if (T) gets(s); if (judge()) printf("YES\n");
else printf("NO\n");
}
return ;
}

A

Codeforces Round 212 Div 2 报告(以前没写完,现在也没心情补了,先就这样吧)的更多相关文章

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

    题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...

  2. Codeforces Round #212 (Div. 2) C. Insertion Sort

    C. Insertion Sort Petya is a beginner programmer. He has already mastered the basics of the C++ lang ...

  3. Codeforces Round #212 (Div. 2) D. Fools and Foolproof Roads 并查集+优先队列

    D. Fools and Foolproof Roads   You must have heard all about the Foolland on your Geography lessons. ...

  4. Codeforces Round #603 (Div. 2) A,B,C,D【E题待补】

    #include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int _; cin&g ...

  5. Codeforces Round #676 (Div. 2) A - D个人题解(E题待补)

    1421A. XORwice 题目链接:Click Here // Author : RioTian // Time : 20/10/18 #include <bits/stdc++.h> ...

  6. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  7. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  8. Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题

    Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...

  9. Codeforces Round #281 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...

随机推荐

  1. 为什么Hbase能实现快速的查询

    你的快速是指什么? 是根据亿级的记录中快速查询,还是说以实时的方式查询数据. A:如果快速查询(从磁盘读数据),hbase是根据rowkey查询的,只要能快速的定位rowkey,  就能实现快速的查询 ...

  2. UVALive 2323 Modular Multiplication of Polynomials(模拟)

    这是一个相对简单的模拟,因为运算规则已经告诉了我们,并且比较简单,不要被吓到…… 思路:多项式除以另外一个多项式,如果能除,那么他的最高次一定被降低了,如果最高次不能被降低,那说明已经无法被除,就是题 ...

  3. 一个很好的通用 excel 导出工具类

    此类用主要 jxl +注解+流 实现扩展性很强,jxl性能会比poi好一点,值得我们学习. package oa.common.utils; import java.io.OutputStream; ...

  4. This compilation unit is not on the build path SVN

    This compilation unit is not on the build path of a Java project 解决办法​ 把项目导入STS(基于Eclipse)时,项目出现问题, ...

  5. gen_grant_dml.sql

    set echo off feedback off verify off pagesize 0 linesize 120 define v_grantee                = & ...

  6. 神经网络joone_engin模式识别示范,eclipse

    链接: http://pan.baidu.com/s/1kVRducv 密码: junw

  7. 安卓图表引擎AChartEngine(六) - 框架源码结构图

    包结构: org.achartengine: org.achartengine.model: org.achartengine.renderer: org.achartengine.tools: 安卓 ...

  8. 编译内核启用iptables及netfilter

    在Network Packet Filtering Framework(Netfilter)一节中还有两个额外的配置节——Core Netfilter Configuration(核心Netfilte ...

  9. IFeatureLayer

      All Properties Methods Inherited Non-inherited Description AreaOfInterest The default area of inte ...

  10. JavaScript运行原理解析

    原文:1.http://blog.csdn.net/liaodehong/article/details/50488098 2.Stack的三种含义 (阮一峰) 3. http://lib.csdn. ...