Bzoj 1709: [usacos2007 Oct] Super paintball

Source: Internet
Author: User
Description

Cows recently bought a set of simulated color bullet game devices from the famous dairy manufacturer tycow (similar to the ultimate version of CS ). Bessie made them play the game lawn into a matrix of N * n (1 <= n <= 100) units and listed her K (1 <= k <= 100,000) opponent's position on the lawn. Then she came to you with this table and hoped that you could help her calculate a data. In this game, cows can use a bullet gun to shoot at any of the eight directions. The eight directions are: north, south, east, west, and 45 ° angle between the four directions: Northeast, southeast, northwest, and southwest. Bessie wishes you to tell her how many options she has if she wants to stand on a grid that can hit all her opponents. Of course, Bessie can stand on the same grid with one of her opponents, and in this case, you can think that Bessie can hit the opponent standing in the same grid with her. Input

* Row 1st: two integers separated by spaces: N and K

* 2nd .. row k + 1: line I + 1 separates the integer r_ I and C_ I with two spaces. This describes the position of the I-head cow, indicating that she is standing in row r_ I and output in column C_ I.

* Row 1st: output an integer, indicating the number of cells that Bessie can select.

Question:

Calculate the number of rows, columns, primary diagonal lines, sub-diagonal lines, and cells respectively.

If * 3 = K in the row + column + two diagonal lines in a grid meets the meaning of the question.

Code:

#include<cstdio>using namespace std;int n,k;int hang[105],lie[105],a[205],b[400];int c[105][105];int main(){    scanf("%d%d",&n,&k);    for(int i=1,x,y;i<=k;i++){        scanf("%d%d",&x,&y);        hang[x]++;        lie[y]++;        a[x+y]++;        b[x-y+n]++;        c[x][y]++;    }    int ans=0;    for(int i=1;i<=n;i++){        for(int j=1;j<=n;j++){            if(hang[i]+lie[j]+a[i+j]+b[i-j+n]-c[i][j]*3==k){                ans++;            }        }    }    printf("%d\n",ans);         return 0;}

Bzoj 1709: [usacos2007 Oct] Super paintball

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.