#include<bits/stdc++.h>
using namespace std;
const int maxN=20;
int n,m;
char a[maxN][maxN];
struct figura
{
int n,m;
int a[5][5];
};
struct tip
{
int nrrot;
figura fig[4];
};
tip v[5]=
{
{
1,
{ {2,2, { {1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}}
}
},
{
2,
{ {1,4, { {1,1,1,1},{0,0,0,0},{0,0,0,0},{0,0,0,0}}},
{4,1, { {1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}}}
}
},
{
2,
{ {2,3, { {0,1,1,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}},
{3,2, { {1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}}}
}
},
{
2,
{ {2,3, { {1,1,0,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}}},
{3,2, { {0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}}}
}
},
{
4,
{ {2,3, { {0,1,0,0},{1,1,1,0},{0,0,0,0},{0,0,0,0}}},
{2,3, { {1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}}},
{3,2, { {0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}}},
{3,2, { {1,0,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}}}
}
}
};
int sol[10];
int main()
{
cin>>n>>m;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
cin>>a[i][j];
for(int f=0;f<5;f++) //figura
{
for(int k=0;k<v[f].nrrot;k++) //rotatia
{
int l,c;
l=v[f].fig[k].n;
c=v[f].fig[k].m;
for(int ic=0;ic+l-1<n;ic++)
for(int jc=0;jc+c-1<m;jc++)
{
for(char ch='a';ch<='z';ch++)
{
bool ok=1;
for(int i=0;i<l;i++)
for(int j=0;j<c;j++)
{
if(v[f].fig[k].a[i][j]==1 && a[ic+i][jc+j]!=ch) ok=0;
if(v[f].fig[k].a[i][j]==0 && a[ic+i][jc+j]==ch) ok=0;
}
if(ok) sol[f]++;
}
}
}
}
for(int i=0;i<5;i++)
cout<<sol[i]<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |