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题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...
随机推荐
- Java 向Hbase表插入数据报(org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac
org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac 代码: //1.create HTa ...
- hdu 1180诡异的楼梯(bfs)
诡异的楼梯 Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submis ...
- 转:Selenium2.0 click()不生效的解决办法
除了http://573301735.com/?p=5126讲的,昨天又发现一个让我1个小时生不如死的问题,就是使用两个不同的配置文件来初始化driver,findelement方法获取到的坐标居然不 ...
- 篇一:eclipse创建maven工程
一.概览 maven创建的项目主要分为三类:war(网页工程).jar(Java工程).pom(父工程); war:网页工程,包含webapp,用于view层 jar:Java工程,用于提供方法.se ...
- PAT乙1001
我脑洞大了..... 以为是个找规律..... 原来只是模拟..... 我相信肯定是有规律的..... 但是我就是不愿意了..... #include<cstdio> #include&l ...
- 一个简单的基于HTTP协议的屏幕共享应用
HTTP协议可以能是应用层协议里使用最广泛并且用途最多样的一个了.我们一般使用HTTP协议来浏览网页,但是HTTP协议还用来做很多其它用途.对开发人员来讲很常见的一种就是用HTTP协议作为各种版本控制 ...
- android4.0蓝牙使能的详细解析(转)
源:http://www.cnblogs.com/xiaochao1234/p/3818193.html 本文详细分析了android4.0 中蓝牙使能的过程,相比较android2.3,4.0中的蓝 ...
- 1025:To the max(DP)
Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any ...
- new/delete 和 new[]/delete[]
浅谈 C++ 中的 new/delete 和 new[]/delete[] 在 C++ 中,你也许经常使用 new 和 delete 来动态申请和释放内存,但你可曾想过以下问题呢? new 和 d ...
- Eclipse 配置工程
Eclipse改UTF-8 Window->Preferences->General->Workspace->Text file Encoding Eclipse配置tomca ...