贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
/*
贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; const int MAXN = ;
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=; i<=; ++i) scanf ("%s", s[i] + );
for (int i=; i<=; ++i)
{
for (int j=; j<=; ++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) % == && (y2 - y1) % == ) puts ("YES");
else puts ("NO");
} return ;
}
贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet的更多相关文章
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
- 贪心+构造 Codeforces Round #277 (Div. 2) C. Palindrome Transformation
题目传送门 /* 贪心+构造:因为是对称的,可以全都左一半考虑,过程很简单,但是能想到就很难了 */ /************************************************ ...
- 数学 Codeforces Round #219 (Div. 2) B. Making Sequences is Fun
题目传送门 /* 数学:这题一直WA在13组上,看了数据才知道是计算cost时超long long了 另外不足一个区间的直接计算个数就可以了 */ #include <cstdio> #i ...
- 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...
- 【DFS】【贪心】Codeforces Round #411 (Div. 1) C. Ice cream coloring
对那个树进行dfs,在动态维护那个当前的冰激凌集合的时候,显然某种冰激凌仅会进出集合各一次(因为在树上形成连通块). 于是显然可以对当前的冰激凌集合贪心染色.暴力去维护即可.具体实现看代码.map不必 ...
- 【贪心】Codeforces Round #407 (Div. 2) A. Anastasia and pebbles
贪心地一个一个尽可能往口袋里放,容易发现和顺序无关. #include<cstdio> #include<iostream> using namespace std; type ...
- 数学 Codeforces Round #282 (Div. 2) B. Modular Equations
题目传送门 题意:a % x == b,求符合条件的x有几个 数学:等式转换为:a == nx + b,那么设k = nx = a - b,易得k的约数(>b)的都符合条件,比如a=25 b=1 ...
- 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. ...
- 数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun
题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string& ...
随机推荐
- Please enter a commit message to explain why this merge is necessary.
Please enter a commit message to explain why this merge is necessary. 请输入提交消息来解释为什么这种合并是必要的 git 在pul ...
- ASP.net MVC+ViewData VS ViewBag
在使用MVC框架的过程中,往界面传值,我们使用的ViewData.如ITOO部分代码图解: 当然除了ViewData,我们还能够使用同卵兄弟(ViewBag)来完毕相同的功能,详情 ...
- IPython与Jupyter notebook 安装与配置,插件扩展,主题,PDF输出
基于 python2.7.13 32-bit版本安装 1.安装pyreadline https://pypi.python.org/pypi/pyreadline 下载对应的32位版本 安装Micro ...
- Coding Ninja 修炼笔记 (1)
大家好啊~我又回来了. 这次主要是给大家带来一些提升 Coding 效率的建议. 效率都是一点一滴优化出来的,虽然每一条建议给你带来的提升可能都不大,但是积累起来,仍然是一股不可忽视的力量. 第一条 ...
- 一个程序员对微信小程序的看法
我们公司用两周的时间开发了一款微信小程序,叫<如e支付>,大家可以去体验一下.由于接口都是写好的,所以开发起来很快.我将从4个不同的角度来介绍我对微信小程序的理解. 1.技术的角度 ...
- web 界面设计---大道至简
http://www.cnblogs.com/coder2012/p/4023442.html 一个非常精简的webpy页面博客 qing.weibo.com 新浪的轻微博也不错精简
- 设计模式-(11)组合模式 (swift版)
一,概念 组合模式(Composite Pattern),又叫部分整体模式,是用于把一组相似的对象当作一个单一的对象.组合模式依据树形结构来组合对象,用来表示部分以及整体层次.这种类型的设计模式属于结 ...
- JDBC各种数据库连接URL关键代码
通过JDBC连接数据库时,各个数据库有着不同的URL格式,为了方便大家使用,我在以下提供了常见的7种数据库连接示例代码,请根据实际需要进行相应的更改. 1.Oracle数据库 Class.forNam ...
- String的属性和方法
package com.zzu.java.array; public class TtString { /** * @author 程路超 * @param args */ public static ...
- 几种判断一个整数是否是2的n次方幂的方法
1:简单除法 int i = 128: //待判断的整数 int count = 1: //待判断的整数是2的count次方while (i){if (2 == i){printf("Y ...