bruteforce
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> resultGrid(vector<vector<int>>& image, int t) {\n        int m = image.size(),n=image[0].size();\n        vector<vector<int>> result(m, vector<int>(n));\n        vector<vector<vector<int>>> vec(m, vector<vector<int>>(n));\n          \n        \n        for(int i=0;i<m-2;i++)\n        {\n            for(int j=0;j<n-2;j++)\n            {\n                int sum=0;\n                for(int k=0;k<3;k++)\n                {\n                    for(int l=0;l<3;l++)\n                    {\n                        sum+= image[i+k][j+l];\n                    }\n                }\n                for(int k=0;k<2;k++)\n                {\n                    for(int l=0;l<2;l++)\n                    {\n                        if(abs(image[i+k][j+l]-image[i+k+1][j+l])<=t && abs(image[i+k][j+l]-image[i+k][j+l+1])<=t)\n                        continue;\n                        else\n                        {\n                            k=3;\n                            sum=INT_MAX;\n                            break;\n                        }\n                    }\n                }\n                \n                for(int a=i;a<i+2;a++)\n                    if(abs(image[a][j+2]-image[a+1][j+2])>t)\n                    {\n                        sum=INT_MAX;\n                        break;\n                    }\n                \n                for(int a=j;a<j+2;a++)\n                    if(abs(image[i+2][a]-image[i+2][a+1])>t)\n                    {\n                        sum=INT_MAX;\n                        break;\n                    }   \n                if(sum!=INT_MAX)\n                {\n                    \n                   for(int k=0;k<3;k++)\n                    {\n                        for(int l=0;l<3;l++)\n                        {\n                            vec[i+k][j+l].push_back(sum/9);\n                        }\n                    }\n                }\n                \n            }\n        }\n\n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                int sum=0;\n\n                for(auto k:vec[i][j])\n                sum+=k;\n                if(vec[i][j].size()==0)\n                result[i][j]=image[i][j];\n                else\n                result[i][j]=sum/vec[i][j].size();\n            }\n        }\n        return result;\n\n\n          \n    }\n};\n```
['C++']