#include <iostream>
using namespace std;
struct figura {
int n;
int m;
int a[4][4];
};
struct varf {
int valoare;
figura fig[4];
};
varf form[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 n, m, x, y, litera, ok;
int sol[5];
char a[10][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 pas=0; pas<5; pas++){
for(int rotatia=0; rotatia < form[pas].valoare; rotatia++){
x=form[pas].fig[rotatia].n;
y=form[pas].fig[rotatia].m;
for(int i=0; i+x-1 < n; i++){
for(int j=0; j+y-1 < m; j++){
for(litera='a'; litera <= 'z'; litera++){
ok=1;
for(int ii=0; ii < x; ii++){
for(int jj=0; jj < y; jj++){
if(form[pas].fig[rotatia].a[ii][jj] == 1 && a[i+ii][j+jj] != litera)
ok=0;
if(form[pas].fig[rotatia].a[ii][jj] == 0 && a[i+ii][j+jj] == litera)
ok=0;
}
}
sol[pas]+=ok;
}
}
}
}
}
for(int i=0; i<5; i++)
cout<<sol[i]<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
360 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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
380 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |