A. Two Semiknights Meet

  题目大意:有一个8x8的棋盘,上面放有两个骑士,骑士以“田字”的方式走。每个方格都被定义为good或者bad,问骑士能否在good的格子中相遇?

  由于骑士最初位于good的格子中,并且骑士可以按原路返回,所以只需判断骑士是否能够相遇就行了(相遇后可以返回任意一个骑士的初始位置)。根据骑士的移动特性,两个骑士位置的行和列之差应该为4的倍数。

  自己开始的时候,还试图计算相遇位置,然后bfs逐个验证,想麻烦了...

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <cstring>
  4. #include <cstdlib>
  5. using namespace std;
  6. typedef pair<int, int> pii;
  7.  
  8. const int N = ;
  9. int m[N][N];
  10. pii knight[];
  11.  
  12. bool judge()
  13. {
  14. int row_diff = abs(knight[].first - knight[].first);
  15. int col_diff = abs(knight[].second - knight[].second);
  16. if (row_diff % != || col_diff % != ) return false;
  17. return true;
  18. }
  19.  
  20. int main()
  21. {
  22. #ifdef LOCAL
  23. freopen("in", "r", stdin);
  24. #endif
  25. int T;
  26. scanf("%d", &T);
  27. getchar();
  28. while (T--)
  29. {
  30. // read data
  31. char s[];
  32. int p = ;
  33. memset(m, , sizeof(m));
  34. for (int i = ; i < ; ++i)
  35. {
  36. gets(s);
  37. for (int j = ; j < ; ++j)
  38. {
  39. if (s[j] == '#') m[i][j] = ;
  40. else if (s[j] == 'K')
  41. {
  42. m[i][j] = ;
  43. knight[p++] = make_pair(i,j);
  44. }
  45. }
  46. }
  47. if (T) gets(s);
  48.  
  49. if (judge()) printf("YES\n");
  50. else printf("NO\n");
  51. }
  52. return ;
  53. }

A

Codeforces Round 212 Div 2 报告(以前没写完,现在也没心情补了,先就这样吧)的更多相关文章

  1. 贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet

    题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...

  2. 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 ...

  3. 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. ...

  4. 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 ...

  5. Codeforces Round #676 (Div. 2) A - D个人题解(E题待补)

    1421A. XORwice 题目链接:Click Here // Author : RioTian // Time : 20/10/18 #include <bits/stdc++.h> ...

  6. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  7. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  8. 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 ...

  9. Codeforces Round #281 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...

随机推荐

  1. 转: JMeter技巧集锦

    from:http://java.chinaitlab.com/tools/355421.html JMeter 是一个流行的用于负载测试的开源工具, 具有许多有用的功能元件,如线程组(thread ...

  2. mybatis generator Date类型时间丢失

    开篇 本次项目换用了Oracle数据库,讲真,真的不好用,不太喜欢,比较喜欢轻量级的MySQL但是不得不说从Oracle的严谨中学到不少好东西. <resultMap id="Base ...

  3. CentOS服务端口开放

    #例如开放81端口iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPTiptables -I OUTPUT -o eth0 -p tcp --sp ...

  4. java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to com.bjsxt.service.UserServiceImpl01_AOP.

    对于Spring AOP 采用两种代理方法,一种是常规JDK,一种是CGLIB,我的UserDao了一个接口IUserDao,当代理对象实现了至少一个接口时,默认使用 JDK动态创建代理对象,当代理对 ...

  5. ecb, 找不到button

    我问了一下,http://stackoverflow.com/questions/17667554/when-configuring-ecb-i-cant-found-button-save-for- ...

  6. 安卓开发之探秘蓝牙隐藏API(转)

    源:http://www.cnblogs.com/xiaochao1234/p/3793172.html 上次讲解Android的蓝牙基本用法,这次讲得深入些,探讨下蓝牙方面的隐藏API.用过Andr ...

  7. 基于ATmgea8单片机设计的加热控制系统(转)

    源:http://blog.163.com/zhaojun_xf/blog/static/3005058020085102562729/ 1 引言 温度是工业生产中主要的被控参数之一,与之相关的各种温 ...

  8. 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 ...

  9. article标签

    <html><head lang="en"> <meta charset="UTF-8"> <title>富士康 ...

  10. Android PopupWindow的使用技巧(转)

    Android PopupWindow的使用技巧 PopupWindow是Android上自定义弹出窗口,使用起来很方便. PopupWindow的构造函数为 public PopupWindow(V ...