暴力搜索但0分,疑惑中,求助
查看原帖
暴力搜索但0分,疑惑中,求助
560912
CNfzfz1368楼主2024/1/29 14:22
#include<bits/stdc++.h>
using namespace std;

int n,m,k;

int main()
{
    cin>>n>>m>>k;
    int myworld[n][n] = {};
    int fire[13][2] = {{-2,0},{-1,0},{0,0},{1,0},{2,0},
                        {0,-1},{0,-2},{0,1},{0,2},
                        {-1,-1},{-1,1},{1,-1},{1,1}};
    int stone[25][2] = {{-2,-2},{-2,-1},{-2,0},{-2,1},{-2,2},
                        {-1,-2},{-1,-1},{-1,0},{-1,1},{-1,2},
                        {0,-2},{0,-1},{0,0},{0,1},{0,2},
                        {1,-2},{1,-1},{1,0},{1,1},{1,2},
                        {2,-2},{2,-1},{2,0},{2,1},{2,2}};
    int x,y;
    
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        for(int j=0;j<13;j++)
        {
            if(x+fire[j][0] >=0 && x+fire[j][0] <n && y+fire[j][1] >=0 && y+fire[j][1] <n)
                myworld[x+fire[j][0]][y+fire[j][1]] = 1;
        }
    }
    for(int i=0;i<k;i++)
    {
        cin>>x>>y;
        for(int j=0;j<25;j++)
        {
            if(x+stone[j][0] >=0 && x+stone[j][0] <n && y+stone[j][1] >=0 && y+stone[j][1] <n)
                myworld[x+stone[j][0]][y+stone[j][1]] = 1;
        }
    }
    
    int res = 0;
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(myworld[i][j] == 0)
            {
                res++;
            }
        }
    }
    
    cout<<res;
    
    return 0;
}
2024/1/29 14:22
加载中...