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 ...
随机推荐
- Android进度加载的Loading效果
网上看到的一个开源项目的loading效果,效果很赞,记录一下: 开源项目地址如下:https://github.com/RomainPiel/Titanic
- Android 开发框架介绍
一.概述 现android开发有很多开发框架使用,做App不一定用到框架,但好框架的思想也是值得学习.选择合适的开发框架可提供实用功能,简化项目开发提升效率. 二.Afinal框架 简介 Afinal ...
- Linux iostat监测IO状态
Linux iostat监测IO状态 http://www.orczhou.com/index.php/2010/03/iostat-detail/
- Java SE 6 新特性: 对脚本语言的支持
2006 年底,Sun 公司发布了 Java Standard Edition 6(Java SE 6)的最终正式版,代号 Mustang(野马).跟 Tiger(Java SE 5)相比,Musta ...
- Oracle11g导入*.dmp数据文件
imp命令导入数据:imp username/password@SID file=XXX.dmp fromuser=XXX touser=XXX tables=(XXX,XXX) [ignore=y ...
- 深入学习Android有关网络连接的内容
基于实际项目中碰到的些许问题,开始重新深入学习Android网络连接有关知识. Android的4.1.2版本的AndroidHttpClient模块setSoTimeout之后实际超时时间和设置的时 ...
- iOS开发常用输入校验
1.数字字符校验 #define NUMBERSPERIOD @"0123456789." - (BOOL)CheckInput:(NSString *)string { NSCh ...
- 关于在Eclipse里面启动了服务,但是localhost:8080无法访问的问题:
今天eclipse重新换了一个然后写项目,结果发生了一些bug,当在Tomca服务开启之后,浏览器端输入localhost:8080无法访问,以为是服务器没有搞定,检查了没问题,百度了一下有很多乱七八 ...
- ASP.NET性能优化小结(ASP.NET&C#)
ASP.NET: 一.返回多个数据集 检查你的访问数据库的代码,看是否存在着要返回多次的请求.每次往返降低了你的应用程序的每秒能够响应请求的次数.通过在单个数据库请求中返回多个结果集,可以减少与数据库 ...
- [HIve - LanguageManual] XPathUDF
Documentation for Built-In User-Defined Functions Related To XPath UDFs xpath, xpath_short, xpath_in ...