-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCHFDORA.cpp
More file actions
executable file
·54 lines (53 loc) · 845 Bytes
/
CHFDORA.cpp
File metadata and controls
executable file
·54 lines (53 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t, m, n, i, j;
cin>>t;
while(t--)
{
cin>>n>>m;
int a[n][m];
for(i=0;i<n;i++)
for(j=0;j<m;j++)
cin>>a[i][j];
if(n<3 || m<3)
cout<<(n*m)<<"\n";
else
{
int result = n*m, k=1;
int o = min(m,n);
if(o%2==0)
o--;
o/=2;
for(k=1;k<=o;k++)
{
for(i=k;i<n-k;i++)
{
for(j=k;j<m-k;j++)
{
bool flag = true;
for(int l=1;l<=k;l++)
{
if(a[i-l][j]==a[i+l][j] && a[i][j-l]==a[i][j+l])
continue;
else
{
flag=false;
break;
}
}
if(flag)
result++;
}
}
}
cout<<result<<"\n";
}
}
return 0;
}