Language: C++

#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read()
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x > 0 (x != 0) ***
{
	if(!x)
		return ;
	write(x / 10);
	putchar(x % 10 + '0');
}
#define maxn 3100
#define int LL
int n, m;
int a[maxn][maxn];
int s1[maxn][maxn], s2[maxn][maxn]; // s1 : '/' ; s2 : '\'
#undef int
int main()
{
	#define int LL
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	string s;
	for(int i = 1; i <= n; i ++)
	{
		cin >> s;
		for(int j = 1; j <= m; j ++)
			a[i][j] = s[j - 1] == '#';
	}
	for(int i = 2; i <= n + m; i ++) // x + y
		for(int j = max(1, i - m); j <= min(n, i - 1); j ++) // x
			s1[j][i - j] = s1[j - 1][i - (j - 1)] + a[j][i - j];
	for(int i = 1 - n; i <= m - 1; i ++) // y - x
		for(int j = max(1, 1 - i); j <= min(n, m - i); j ++) // x
			s2[j][i + j] = s2[j - 1][i + (j - 1)] + a[j][i + j];
//	cout << endl;
//	for(int i = 1; i <= n; i ++)
//	{
//		for(int j = 1; j <= m; j ++)
//			cout << s1[i][j] << ' ';
//		cout << endl;
//	}
//	cout << endl;
//	for(int i = 1; i <= n; i ++)
//	{
//		for(int j = 1; j <= m; j ++)
//			cout << s2[i][j] << ' ';
//		cout << endl;
//	}
//	cout << endl;
	int Ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= m; j ++)
		{
			for(int k = 1; k <= n; k ++)
			{
				if(i - k > 0 && j - k > 0 && a[i][j - k] && a[i - k][j])
				{
					int d = i + j + k;
					Ans += s1[d - j - 1][d - (d - j - 1)] - s1[i][d - i];
				}
				if(i + k <= n && j + k <= m && a[i + k][j] && a[i][j + k])
				{
					int d = i + j - k;
					Ans += s1[i - 1][d - (i - 1)] - s1[d - j][d - (d - j)];
				}
				if(i - k > 0 && j + k <= m && a[i - k][j] && a[i][j + k])
				{
					int d = j - i - k;
					Ans += s2[j - d - 1][d + (j - d - 1)] - s2[i][d + i];
				}
				if(i + k <= n && j - k > 0 && a[i + k][j] && a[i][j - k])
				{
					int d = j - i + k;
					Ans += s2[i - 1][d + (i - 1)] - s2[j - d][d + (j - d)];
				}
				int tot = 0;
				if(i - k > 0 && a[i - k][j])
					tot ++;
				if(j - k > 0 && a[i][j - k])
					tot ++;
				if(i + k <= n && a[i + k][j])
					tot ++;
				if(j + k <= m && a[i][j + k])
					tot ++;
				if(tot == 3)
					Ans ++;
				else if(tot == 4)
					Ans += 4;
			}
		}
	}
	cout << Ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:32: error: no matching function for call to 'max(int, long long int)'
   42 |                 for(int j = max(1, i - m); j <= min(n, i - 1); j ++) // x
      |                             ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:42:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |                 for(int j = max(1, i - m); j <= min(n, i - 1); j ++) // x
      |                             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:42:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |                 for(int j = max(1, i - m); j <= min(n, i - 1); j ++) // x
      |                             ~~~^~~~~~~~~~
a.cc:45:32: error: no matching function for call to 'max(int, long long int)'
   45 |                 for(int j = max(1, 1 - i); j <= min(n, m - i); j ++) // x
      |                             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:45:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |                 for(int j = max(1, 1 - i); j <= min(n, m - i); j ++) // x
      |                             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:45:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |                 for(int j = max(1, 1 - i); j <= min(n, m - i); j ++) // x
      |                             ~~~^~~~~~~~~~