Thứ Tư, 27 tháng 4, 2022

THANHPHO C++

#include<bits/stdc++.h>
using namespace std;

int m,n,k;
int a[1000][1000],b[1000][1000];
int d[1000000];
int x[9]={0,-1,-1,-1,0,1,1,1,0};
int y[9]={0,-1,0,1,1,1,0,-1,-1};

void input()
{
    cin >> m >> n >> k;
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
            cin >> a[i][j];
}


void solve()
{
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            for(int p=1;p<=8;p++)
                b[i][j]=b[i][j]+a[i+x[p]][j+y[p]];
            d[b[i][j]]++;
        }
    int c;
    for(int i=1;i<=k;i++)
    {
        cin>>c;
        if(d[c]>0) cout<<1<<" ";
        else cout<<0<<" ";
    }
}
int main()
{
    freopen("thanhpho.inp","r",stdin);
    freopen("thanhpho.out","w",stdout);
    input();
    solve();
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.