cf 1015 E1. Stars Drawing (Easy Edition)
标签:== als 暴力 getchar c++ stars win bsp false
暴力把能填的都填,用vis数组标记,如果出现填不了的输出-1
#includeusing namespace std;
char graph[110][110];
int vis[110][110];
int xx[10010];
int yy[10010];
int si[10010];
int tot;
int n,m;
bool check(int i,int j,int k)
{
if(i-k1||i+k>n||j-k1||j+k>m)
return false;
return true;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i)
{
getchar();
for(int j=1;j)
{
scanf("%c",&graph[i][j]);
}
}
for(int i=1;i)
{
for(int j=1;j)
{
if(graph[i][j]==‘*‘)
{
int index=-1;
for(int k=1;check(i,j,k);k++)
{
if(graph[i+k][j]==‘*‘&&graph[i-k][j]==‘*‘&&graph[i][j+k]==‘*‘&&graph[i][j-k]==‘*‘)
{
index=k;
vis[i][j]=vis[i+k][j]=vis[i-k][j]=vis[i][j+k]=vis[i][j-k]=1;
}
else
break;
}
if(index!=-1)
{
xx[++tot]=i;
yy[tot]=j;
si[tot]=index;
}
}
}
}
for(int i=1;i)
{
for(int j=1;j)
{
if(graph[i][j]==‘*‘&&vis[i][j]==0)
{
printf("-1\n");
return 0;
}
}
}
printf("%d\n",tot);
for(int i=1;i)
printf("%d %d %d\n",xx[i],yy[i],si[i]);
}
cf 1015 E1. Stars Drawing (Easy Edition)
标签:== als 暴力 getchar c++ stars win bsp false
原文地址:https://www.cnblogs.com/lishengkangshidatiancai/p/10285552.html
评论