zoukankan      html  css  js  c++  java
  • 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 ≤ n1 ≤ 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");
    }
  • 相关阅读:
    linux下postgresql的c程序编译问题
    Linux下Sublime Text 2中文显示及中文输入问题[转][ubuntu 10.10]
    linux英文斜体乱码 【ubuntu 10.10】
    dropbox无法访问后国内网盘对比选择
    Linux查看系统信息的一些命令及查看已安装软件包的命令(转)
    linux配置ssh 【ubuntu 10.10】
    error: failed to push some refs【Linux】【Git】
    一些曾经收藏的话
    Linux系统源码安装过程中的prefix选项【转】
    LINUX GBK>UTF8文件编码批量转换脚本[转]
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4989279.html
Copyright © 2011-2022 走看看