UVa 201 测试样例,udebug测试数据都可以通过,还是WA

gladinum 2017-11-28 10:30:43
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=137题目链接
下面是我的代码:
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
int kase = 0,n,m;
while(cin>>n>>m)
{
int A[12][12]={0},B[12][12]={0};
char ch[100]={0};
int num[100][2]={0};

for(int i=0; i<m; i++)
cin>>ch[i]>>num[i][0]>>num[i][1];
for(int j=0; j<m; j++)
{
if(ch[j] == 'H')
A[num[j][0]][num[j][1]] = 1;
if(ch[j] == 'V')
B[num[j][1]][num[j][0]] = 1;
}

int a=1;
int az[100]={0},found=0;
while(a<n)
{
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
int ok=1;
for(int k=0; k<a; k++)
{
if(!A[i][j+k]) ok=0;
if(!A[i+a][j+k]) ok=0;
if(!B[i+k][j]) ok=0;
if(!B[i+k][j+a]) ok=0;
}
if(ok)
{
found=1;
az[a]++;
}
}
}
a++;
}
if(kase)
cout<<endl<<"**********************************"<<endl;
if(!kase)
cout<<"Problem #"<<++kase<<endl<<endl;
else
cout<<endl<<"Problem #"<<++kase<<endl<<endl;
if(found)
{
for(int i=1; az[i]; i++)
cout<<az[i]<<" square (s) of size "<<i<<endl;
}
else
cout<<"No completed squares can be found."<<endl;
}

return 0;
}
...全文
843 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧