Codeforces Beta Round #51 C. Pie or die 博弈论找规律 有趣的题~
2015-11-23 18:22
295 查看
C. Pie or die
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
http://codeforces.com/contest/55/problem/CDescription
Volodya and Vlad play the following game. There are k pies at the cells of n × m board. Each turn Volodya moves one pie to the neighbouring (by side) cell. If the pie lies at the border of the board then Volodya can move it outside the board, get the pie and win. After Volodya's move, Vlad bans some edge at the border of the board of length 1 (between two knots of the board) so that Volodya is not able to move the pie outside the board through this edge anymore. The question is: will Volodya win this game? We suppose both players follow the optimal strategyInput
First line contains 3 integers, separated by space: 1 ≤ n, m ≤ 100 — dimensions of the board and 0 ≤ k ≤ 100 — the number of pies. Each of the next k lines contains 2 integers, separated by space: 1 ≤ x ≤ n, 1 ≤ y ≤ m — coordinates of the corresponding pie. There could be more than one pie at a cell.
Output
Output only one word: "YES" — if Volodya wins, "NO" — otherwise.
Sample Input
2 2 1 1 2
Sample Output
YES
HINT
题意给你n*m的格子,有k次询问,每次询问就是给你一个球的位置
球可以向四周边相邻的位置移动,如果这个棋子走到边界上,并且这个边界还没有被ban的话,Volodya就胜利了
Volodya先走,然后再ban一个边界
问你K次询问中,Volodya是否能够至少胜利一场
题解:
结论很简单,但是这个怎么来的呢?首先你得ban掉离他最近的边界的边,以及这个边的左边和右边,以及上面和下面
比如下图,红色是棋子所在地,你必须在他到达边界前ban掉五条边
代码:
#include<iostream> #include<stdio.h> using namespace std; int main() { int n,m,k; scanf("%d%d%d",&n,&m,&k); int flag = 1; for(int i=0;i<k;i++) { int x,y; scanf("%d%d",&x,&y); if(x<=5||(n-x)<=4) flag = 0; if(y<=5||(m-y)<=4) flag = 0; } if(flag==0) return puts("YES"); else return puts("NO"); }
相关文章推荐
- 插入式注解处理API(Pluggable Annotation Processing API)
- JAVA精准计算小工具
- elisp之函数
- Facebook获取Key Hashes
- 深入浅出Android Support Annotations
- AR--摄像机标定
- Hangover poj1003
- 【Android进阶学习】监听EditText的变化
- Ubuntu14.04 安装 tensorflow
- 区间相关贪心问题
- 《Objective-c开发范例代码大全》
- HighCharts、EChart图表X轴纵向显示
- 区间相关贪心问题
- ASP.NET动态网站制作(29)-- 正则
- coco2d-js 无法加载网络图片(Failed to execute 'texImage2D' on ‘WebGLRenderin
- socket被dce使用的情况
- 如何动态设置EditText输入的文字为密码形式
- kali的源
- 三、JavaScript语句
- 修改 “嗨加游-Prefix.pch” 或者 “嗨加游-Info.plist ” 方法