首页 > 其他分享 >abc045d

abc045d

时间:2023-06-20 10:58:59浏览次数:36  
标签:cnt 格子 abc045d LL ++ int include

https://atcoder.jp/contests/abc045/tasks/arc061_b

// https://atcoder.jp/contests/abc045/tasks/arc061_b
// 注意到每个格子染色仅能影响到周围范围的格子, 因而对N个染色点进行枚举
// 为了不重复, 仅枚举每个染色点影响到的右下侧共3*3个格子
// 统计每个格子被覆盖的次数, 而0为所有的3*3方框数减去1~9
// 注意, 需要限制边界, 使得能够将被枚举的格子处能建立3*3方框
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
LL h, w, n;

void solv()
{
    cin >> h >> w >> n;
    map<PII, LL> mp;
    int a, b;
    for (int k = 1; k <= n; k ++)
    {
        cin >> a >> b;
        for (int i = 0; i < 3; i ++)
        {
            for (int j = 0; j < 3; j ++)
            {
                int x = a + i, y = b + j;
                if (x - 2 >= 1 && y - 2 >= 1 && x <= h && y <= w)
                {
                    PII t = {x, y};
                    mp[t] ++;
                }
            }
        }

    }

    vector<LL> v(10, 0);
    LL cnt = 0;
    for (auto const &it : mp)
    {
        v[it.second]++;
        cnt++;
    }
    v[0] = (h - 2) * (w - 2) - cnt;
    for (int i = 0; i < 10; i++)
        cout << v[i] << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solv();
    }
    return 0;
}

标签:cnt,格子,abc045d,LL,++,int,include
From: https://www.cnblogs.com/o2iginal/p/17492985.html

相关文章