#include <iostream>
using namespace std;
struct figura {
int n;
int m;
int a[4][4];
};
struct tip {
int nr;
figura fig[4];
};
tip f[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,i,j,t,r,lin,col,ii,jj,litera,sol[5];
char a[10][10];
int main() {
cin>>n>>m;
for (i=0;i<n;i++)
for (j=0;j<m;j++)
cin>>a[i][j];
for (t=0;t<5;t++) {
//verificam de cate ori apare figura f[t] cu f[t].nr rotatii
for (r=0;r<f[t].nr;r++) {
lin=f[t].fig[r].n;
col=f[t].fig[r].m;
//incercam toate locurile din matrice unde se poate suprapune figura
for (ii=0;ii+lin-1<n;ii++) {
for (jj=0;jj+col-1<m;jj++) {
for (litera='a';litera<='z';litera++) {
int ok=1;
for (i=0;i<lin;i++) {
for (j=0;j<col;j++) {
if (f[t].fig[r].a[i][j]==1&&a[ii+i][jj+j]!=litera)
ok=0;
if (f[t].fig[r].a[i][j]==0&&a[ii+i][jj+j]==litera)
ok=0;
}
}
sol[t]+=ok;
}
}
}
}
}
for(i=0;i<5;i++)
cout<<sol[i]<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |