#46169: 吸家家


chen971023@gmail.com (ZiaynGZiyaNG)


2024年6月APCS 第二題
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int a[h][w] = {};
    for (int i = 0; i < n; i++)
    {
        int r, c, t, x;
        cin >> r >> c >> t >> x;
        for (int j = 0; j < h; j++)
        {
            for (int l = 0; l < w; l++)
            {
                if (abs(j - r) + abs(l - c) <= t)    - >算曼哈頓距離,只要距離內就要塗色,不用管太多(我卡在這裡TT
                {
                    a[j][l] += x;
                }
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << a[i][j] << " "; 
        }
        cout << endl;
    }
    
}