| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
还没过……WA了三次MLE两次TLE四次……留个代码在这,以后有心情再修改……应该说有能力再修改……哪位好心路过帮我看看T_T#include <iostream>
using namespace std;
char star[51][51],mat[1001][1001];;
__int64 s[50];
int p,q,m,n,x,y;
class cmp
{
public:
bool operator ()()const
{int i,j,k,v,l,c=q-1;
__int64 shu[50];
for (i=0;i<=x;i++)
{
for (v=0,k=i;v<p;v++,k++)
{
shu[v]=0;
for (l=0;l<q;l++)//每一行的和
shu[v]+=mat[k][l]<<l;
}
for (v=0;v<p;v++)
if (s[v]!=shu[v])
break;
if (v<p)
{
for (j=1;j<=y;j++)
{
v=0;
for (l=0;l<p;l++)
{
shu[l]=(shu[l]>>1)+(mat[i+l][j+q-1]<<c);//整数除以二的特点
if(shu[l]!=s[l])
v=1;
}
if (v==0)
return true;
}
}
else
return true;
}
return false;
}
};
int main()
{
int i,j,t,all,ci=0,l;
cmp a;
while(scanf("%d%d%d%d%d",&n,&m,&t,&p,&q) && n)
{
y=m-q;
x=n-p;
for (i=0;i<n;i++)
for (j=0;j<m;j++)
{
cin>>mat[i][j];
mat[i][j]=(mat[i][j]=='0'?0:1);
}
all=0;
if (x<0 || y<0)
{
while(t--)
for(i=0;i<p;i++)
scanf("%s",star+i);
t=0;
}
while(t--)
{
for(i=0;i<p;i++)
for (j=0;j<q;j++)
{
cin>>star[i][j];
star[i][j]=(star[i][j]=='0'?0:1);
}
l=-1;
memset(s,0,sizeof(s));
for(i=0;i<p;i++)
{
++l;
for (j=0;j<q;j++)
s[l]+=(star[i][j]<<j);
}//计算星座每一行对应的__int64数值
if (a())
all++;
}
cout<<"Case "<<++ci<<": "<<all<<endl;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator