贪心/数学 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& ...
随机推荐
- 配置activeMQ
一.加入以下的库 并配置好路径 ws2_32.lib;Mswsock.lib;cppunit.lib;libapr-1.lib;libapriconv-1.lib;libaprutil-1.lib;l ...
- android 开发中用到的工具-持续更新(码农必看)
1. vim 单文件查看改动利器(一直使用支持各种编码各种文件,各种插件),欢迎下载笔者插件 git clone https://github.com/green130181/vim-conf.git ...
- android findVIewById()在线生成工具
今天突然发现一个好工具,能够依据你输入的XML布局文件,自己主动生成findViewById的代码.还支持android annotation的注解方式.真是太棒了.由于我正是使用androidann ...
- my-small.cnf my-medium.cnf my-large.cnf my-huge.cnf
my-small.cnf my-medium.cnf my-large.cnf my-huge.cnf 是 MySQL 默认的几个配置文件.针对不同配置的服务器可以使用不同的配置文件,将你需要的那一个 ...
- BC1.2的一些心得
什么叫DCD DataContact Detect(DCD) 1.首先是DCD 2.然后是Primary detection 3.然后是Secondary detection 检測充电的条件是VBUS ...
- res_d_l =[{'contents':d.contents,'href':d.attrs['href']} for d in rd] 泛型
from selenium import webdriverfrom selenium.webdriver.chrome.options import Options# from selenium.w ...
- iOS设备,fixed布局出问题
window.deviceId = '{{$deviceId}}'; window.iOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? t ...
- 原生js写简单轮播图方式1-从左向右滑动
轮播图就是让图片每隔几秒自动滑动,达到图片轮流播放的效果.轮播图从效果来说有滑动式的也有渐入式的,滑动式的轮播图就是图片从左向右滑入的效果,渐入式的轮播图就是图片根据透明度渐渐显示的效果,这里说的是实 ...
- 【monkey】
在Android文件系统中的存放路径是:/system/framework/monkey.jarMonkey.jar 程序是由一个名为“monkey”的Shell脚本来启动执行,shell脚本在And ...
- aria2 for mac
本文是在安装好homebrew前提下 brew install aria2 然后配置参数 cd ~ mkdir .aria2 cd .aria2 vim aria2.conf 以下配置粘贴进去,红色需 ...