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题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...
随机推荐
- 转: JMeter技巧集锦
from:http://java.chinaitlab.com/tools/355421.html JMeter 是一个流行的用于负载测试的开源工具, 具有许多有用的功能元件,如线程组(thread ...
- mybatis generator Date类型时间丢失
开篇 本次项目换用了Oracle数据库,讲真,真的不好用,不太喜欢,比较喜欢轻量级的MySQL但是不得不说从Oracle的严谨中学到不少好东西. <resultMap id="Base ...
- CentOS服务端口开放
#例如开放81端口iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPTiptables -I OUTPUT -o eth0 -p tcp --sp ...
- java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to com.bjsxt.service.UserServiceImpl01_AOP.
对于Spring AOP 采用两种代理方法,一种是常规JDK,一种是CGLIB,我的UserDao了一个接口IUserDao,当代理对象实现了至少一个接口时,默认使用 JDK动态创建代理对象,当代理对 ...
- ecb, 找不到button
我问了一下,http://stackoverflow.com/questions/17667554/when-configuring-ecb-i-cant-found-button-save-for- ...
- 安卓开发之探秘蓝牙隐藏API(转)
源:http://www.cnblogs.com/xiaochao1234/p/3793172.html 上次讲解Android的蓝牙基本用法,这次讲得深入些,探讨下蓝牙方面的隐藏API.用过Andr ...
- 基于ATmgea8单片机设计的加热控制系统(转)
源:http://blog.163.com/zhaojun_xf/blog/static/3005058020085102562729/ 1 引言 温度是工业生产中主要的被控参数之一,与之相关的各种温 ...
- ural1772 Ski-Trails for Robots
Ski-Trails for Robots Time limit: 1.0 secondMemory limit: 64 MB One of the stages of the Robot Cross ...
- article标签
<html><head lang="en"> <meta charset="UTF-8"> <title>富士康 ...
- Android PopupWindow的使用技巧(转)
Android PopupWindow的使用技巧 PopupWindow是Android上自定义弹出窗口,使用起来很方便. PopupWindow的构造函数为 public PopupWindow(V ...