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");
    }
  • 相关阅读:
    Mybatis 是否支持延迟加载?如果支持,它的实现原理是什么?
    MyBatis 实现一对多有几种方式,怎么操作的?
    利用 ps 怎么显示所有的进程? 怎么利用 ps 查看指定进 程的信息?
    哪个命令专门用来查看后台任务?
    什么是 MyBatis 的接口绑定?有哪些实现方式?
    什么是端到端微服务测试?
    我们如何在测试中消除非决定论?
    什么是持续监测?
    怎么使一个命令在后台运行?
    博客园样式美化(兼容为知笔记)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4989279.html
Copyright © 2011-2022 走看看