Codeforces Beta Round #51 C. Pie or die 博弈论找规律 有趣的题~
C. Pie or die
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/55/problem/C
Description
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 strategy
Input
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 = ;
for(int i=;i<k;i++)
{
int x,y;
scanf("%d%d",&x,&y);
if(x<=||(n-x)<=)
flag = ;
if(y<=||(m-y)<=)
flag = ;
}
if(flag==)
return puts("YES");
else
return puts("NO");
}
Codeforces Beta Round #51 C. Pie or die 博弈论找规律 有趣的题~的更多相关文章
- Codeforces Beta Round #24 D. Broken robot (打表找规律)
题目链接: 点击我打开链接 题目大意: 给你 \(n,j\),再给出 \(m[0]\) 的坐标和\(a[0]-a[n-1]\) 的坐标. 让你输出 \(m[j]\) 的坐标,其中 \(m[i]\) 和 ...
- Codeforces Beta Round #51 B. Smallest number dfs
B. Smallest number Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/pro ...
- Codeforces Beta Round #51 A. Flea travel 水题
A. Flea travel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem ...
- Codeforces Beta Round #51 D. Beautiful numbers 数位dp
D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/p ...
- Codeforces Beta Round #51 D. Beautiful numbers(数位dp)
题目链接:https://codeforces.com/contest/55/problem/D 题目大意:给你一段区间[l,r],要求这段区间中可以整除自己每一位(除0意外)上的数字的整数个数,例如 ...
- Codeforces Beta Round #51 D. Beautiful numbers
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- codeforces 55d//Beautiful numbers// Codeforces Beta Round #51
题意:一个数能整除它所有的位上的数字(除了0),统计这样数的个数. 注意离散化,为了速度更快需存入数组查找. 不要每次memset,记录下已有的长度下符合条件的个数. 数位dp肯定是从高位到低位. 记 ...
- Codeforces Beta Round #9 (Div. 2 Only) E. Interesting Graph and Apples 构造题
E. Interesting Graph and Apples 题目连接: http://www.codeforces.com/contest/9/problem/E Description Hexa ...
- Codeforces Beta Round #6 (Div. 2 Only) C. Alice, Bob and Chocolate 水题
C. Alice, Bob and Chocolate 题目连接: http://codeforces.com/contest/6/problem/C Description Alice and Bo ...
随机推荐
- 【转】APUE学习1:迈出第一步,编译myls.c
原文网址:http://blog.csdn.net/sddzycnqjn/article/details/7252444 注:以下写作风格均学习自潘云登前辈 /******************** ...
- Oracle 课程五之优化器和执行计划
课程目标 完成本课程的学习后,您应该能够: •优化器的作用 •优化器的类型 •优化器的优化步骤 •扫描的基本类型 •表连接的执行计划 •其他运算方式的执行计划 •如何看执行计划顺序 •如何获取执行计划 ...
- gtid
GTID的全称为 global transaction identifier,可以翻译为全局事务标示符,GTID在原始master上的事务提交时被创建.GTID需要在全局的主-备拓扑结构中保持唯一性, ...
- Android之APK文件签名——keytool和jarsigner
一.生成密钥库将位置定位在jdk的bin文件中,输入以下命名行:keytool -genkey -alias ChangeBackgroundWidget.keystore -keyalg RSA - ...
- MyBatis的association示例——MyBatis学习笔记之三
前两篇博文介绍的都是单表映射,而实际上很多时候我们需要用到较复杂的映射.今天学会的association的用法,就是一例,现写出来和大家分享(为简洁起见,ant工程中各文件.目录的布局,以及其它与前面 ...
- 【LeetCode 231】Power of Two
Given an integer, write a function to determine if it is a power of two. 思路: 如果一个数是2的Power,那么该数的二进制串 ...
- LeetCode题解——Regular Expression Matching
题目: 正则表达式的匹配,'.'能匹配任何一个字符,'*'之前必须有一个字符,两个结合起来表示之前那个字符出现0到无穷次. 解法: 一定要注意'*'必须结合前面的字符一起使用. 代码: class S ...
- git 公共服务器
github 私有项目有限制,多了需要收费 bitbucket 无限的私有项目,项目协作人数多了需要收费,刚好和github相反 gitorious 新发现的,不知道有什么特点
- C++ 我想这样用(七)
话接前篇,继续基于对象编程语法的剩余部分: 6.类的const成员函数和const对象 const数据成员:跟const常量一样,只是一个在类里(而且是在构造函数里),一个在类外而已,都必须初始化. ...
- 2016-3-25突然推送大量消息的问题及查找 -- Sangit
起因:2016年3月25日 18:30 左右,突然接到客户投诉,说APP收到大量的任务推送消息,而且点击进去都是一些过期任务,我们将对此展开追踪,查找问题原因. 过程: 1.当时的第一反应是先查看re ...