Codeforces Round 212 Div 2 报告(以前没写完,现在也没心情补了,先就这样吧)
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 报告(以前没写完,现在也没心情补了,先就这样吧)的更多相关文章
- 贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...
- 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 ...
- 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 #603 (Div. 2) A,B,C,D【E题待补】
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int _; cin&g ...
- Codeforces Round #676 (Div. 2) A - D个人题解(E题待补)
1421A. XORwice 题目链接:Click Here // Author : RioTian // Time : 20/10/18 #include <bits/stdc++.h> ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces Round #324 (Div. 2)解题报告
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...
- 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 ...
- Codeforces Round #281 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...
随机推荐
- lucene特殊字符处理
这是个郁闷的问题,今天遇到了,但在lucene中查询的关键字保护有特殊字符,譬如--,会出现如下异常: org.apache.lucene.queryParser.ParseException: Ca ...
- java 随机流
Example10_8.java import java.io.*; public class Example10_8 { public static void main(String args[]) ...
- java 实例变量和类变量的区别
Example4_10.java public class Example4_10 { public static void main(String args[]) { Lader.下底=100; / ...
- Dev之ChartControl控件(一)
ChartControl控件主要包括Chart Title,Legend,Annotations,Diagram,Series五部分:如图: 1. 用RangeControl控件控制ChartCon ...
- Django: 之Apache、Nginx部署以及发送邮件
在这里讲述部署的方法和常见的问题,并给出了在BAE,JAE,SAE等上面部署的实例. Django + nginx + Gunicorn/uwsgi部署方式,参见另一篇:Django部署(nginx) ...
- php源码分析之PHPAPI宏的作用
在PHP源码中,我们经常会看到很多函数前面有个PHPAPI,但这是什么呢? 于是我在php源码/main/php.h中找到了它的定义 #ifdef PHP_WIN32 # include " ...
- lpr
http://flatline.cs.washington.edu/orgs/acm/tutorials/printing/index.html
- emacs redo
c / c/ cg c/ cg c/ tramp: /sudo::/usr/
- 超级素数(sprime)
超级素数(sprime) 题目描述 超级素数是指一个素数,每去掉后面一个数字,总能保证剩下的数为质数,例如:373->37->3这是一个长为3的超级素数. 输入 输入一个整数n (10≤n ...
- Friends and Subsequences
Friends and Subsequences Mike and !Mike are old childhood rivals, they are opposite in everything th ...