zoukankan      html  css  js  c++  java
  • cf 333b

    G - Chips
    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

    Description

    Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original edge to the opposite edge. Gerald loses in this game in each of the three cases:

    • At least one of the chips at least once fell to the banned cell.
    • At least once two chips were on the same cell.
    • At least once two chips swapped in a minute (for example, if you stand two chips on two opposite border cells of a row with even length, this situation happens in the middle of the row).

    In that case he loses and earns 0 points. When nothing like that happened, he wins and earns the number of points equal to the number of chips he managed to put on the board. Help Gerald earn the most points.

    Input

    The first line contains two space-separated integers n and m (2 ≤ n ≤ 1000, 0 ≤ m ≤ 105) — the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≤ xi, yi ≤ n) — the coordinates of the i-th banned cell. All given cells are distinct.

    Consider the field rows numbered from top to bottom from 1 to n, and the columns — from left to right from 1 to n.

    Output

    Print a single integer — the maximum points Gerald can earn in this game.

    Sample Input

    Input
    3 1
    2 2
    Output
    0
    Input
    3 0
    Output
    1
    Input
    4 3
    3 1
    3 2
    3 3
    Output
    1

    Hint

    In the first test the answer equals zero as we can't put chips into the corner cells.

    In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.

    In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).

    这道题其实是比较水的。

    #include<iostream>
    #include<stdio.h>
    #define max1 10005
    using namespace std;
    int main()
    {
        int n,m;
        int r[max1];
        int c[max1];
        scanf("%d%d",&n,&m);
        int ans=0;
        for(int i=0;i<n;i++)
            r[max1]=0,r[max1]=0;
        for(int i=0;i<m;i++)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            r[a]=1;
            c[b]=1;
        }
        for(int i=2;i<n;i++)
        {
            if(!r[i]) ans++;
            if(!c[i]) ans++;
        }
        if(n%2&&!r[n/2+1]&&!c[n/2+1])
            ans--;
        printf("%d
    ",ans);
        return 0;
    }
  • 相关阅读:
    git/gerrit上已经删除了远程分支,本地仍然能看到的解决方法
    bat中查找文件夹下有几个某类型的文件
    ERROR 1045 (28000)问题解决
    Unsupervised Pretraining Transfers well Across Languages
    由声学特征重建语音波形-声码器的最近进展
    神经机器翻译中有用的技巧
    多语种神经机器翻译
    利用Fairseq训练新的机器翻译模型
    转:Linux 系统忘记密码 -> 修改 Ubuntu 虚拟机密码
    Linux安装与配置Tomcat
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/5393496.html
Copyright © 2011-2022 走看看