题意:
n×m的网格中有一些派,每次先手可以移动一个派到相邻的格子,如果这个派本身在边界的话就可以移出去并胜利。
后手每次选择一个边界的格子的一条边封上,以后先手就不能越过这条边移出网格。
求先手是否能胜利。
题解:
很简单的题,但是我没想清楚就交,错了很多次……
派只能从最外一圈的网格移出去,除了四个角之外的格子,只要先手移动到这里后手封上相应的边就不能移出去,而对于四个角,后手必须在先手的派移动带那里之前先封上一条边。
所以只要任何一个派能在4步内移动到边界就可以获胜,否则不能获胜。
//Time:30ms
//Memory:4KB
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <set>
#define MAXN 100010
#define INF 1000000007
#define MP(x,y) make_pair(x,y)
#define FI first
#define SE second
#define EPS 1e-8
using namespace std;
int main()
{
//freopen("/home/moor/Code/input","r",stdin);
int n,m,k;
while(scanf("%d%d%d",&n,&m,&k)==3)
{
if(!k)
{
printf("NO\n");
continue;
}
bool flag=0;
for(int i=0;i<k;++i)
{
int a,b;
scanf("%d%d",&a,&b);
if(a<=5||a>=n-4||b<=5||b>=m-4) flag=1;
}
printf("%s\n",flag?"YES":"NO");
}
return 0;
}