比赛中我最大的失误:输入的两个数字先是宽,再是高,而我没有注意到,按往常先高后宽做的,一直到最后没有AC,事实上思路是对的。
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
char c;
int x,y,cas;
scanf("%d",&cas);
getchar();
while(cas--)
{
scanf("%d%d",&x,&y);
getchar();
for(int i=0; i<y; i++)
{
for(int j=0; j<x; j++)
scanf("%c",&c);
getchar();
}
if(x==1)
printf("%d\n",y*2-2);
else if(y==1)
printf("%d\n",x*2-2);
else if(x%2==0||y%2==0)
printf("%d\n",x*y);
else printf("%d\n",x*y+1);
}
printf("LOL\n");
return 0;
}