Submission

Status:
--P-------

Score: 10

User: Dormon

Problemset: ความหลากหลาย

Language: cpp

Time: 0.003 second

Submitted On: 2024-12-11 22:19:22

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <numeric>
#include <set>

#define debug(...) Debug(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
const bool TEST_CASE = 0;

template<typename T>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* name, T value) {
    std::cout << name << " : " << value << '\n';
}

template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {
    for(auto &x : a) out << x << ' '; 
    return out;
};
template<typename T, typename... Args>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* names, T value, Args... args) {
    const char* comma = strchr(names, ',');
    std::cout.write(names, comma - names) << " : " << value << " | ";
    Debug(comma + 1, args...);
}

void solve(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> grid(n, vector<int>(m, 0));

    for (int i = 0;i < n;i++)
        for (int j = 0;j < m;j++)
            cin >> grid[i][j];

    auto calc = [&](int i, int j) -> bool {
        set<int> s;
        for (int k = i-5;k < i;k++)
            for (int l = j-5;l < j;l++)
                s.insert(grid[k][l]);
        return s.size() >= 5;
    };
    int ans = 0;
    for (int i = 5;i < n;i++)
        for (int j = 5;j < m;j++)
            if (calc(i, j))
                ans++;
            
    cout << ans << '\n';
}

int main()
{
    #ifndef DORMON
        ios_base::sync_with_stdio(0); 
    #endif
    cin.tie(0);
    int q = 1; 
    if (TEST_CASE) cin >> q;
    while (q--){
        solve();
    }
}