我的代码RE了,有谁可以帮我一下
查看原帖
我的代码RE了,有谁可以帮我一下
777556
fantasy2895楼主2023/1/29 20:23
#include<bits/stdc++.h>
using namespace std;
int a[105][105],n,m,k,x,y,c;
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        for(int i=x-1;i<=x+1;i++){
			for(int j=y-1;j<=y+1;j++){
				a[i][j]=1;
			}
		}
	    a[x-2][y]=1;
	    a[x+2][y]=1;
	    a[x][y+2]=1;
	    a[x][y-2]=1;
    }
    for(int i=1;i<=k;i++){
        cin>>x>>y;
        for(int i=x-2;i<=x+2;i++){
			for(int j=y-2;j<=y+2;j++){
				a[i][j]=1;
			}
		}
    }
    for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[i][j]==0){
				c++;
			}
		}
	}
    cout<<c;
    return 0;
}

c++ 提交结果

2023/1/29 20:23
加载中...