URAL 1287. Mars Canals

时间:2023-03-09 14:43:08
URAL 1287. Mars Canals

题目链接

这题挺水,看懂了,就OK。卡了几下内存,还是卡过了。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <ctime>
#include <cmath>
#include <algorithm>
using namespace std;
#define N 1403
int r[N][N][],c[N][N][];
int r1[N][N][],c1[N][N][];
char str[N][N];
int main()
{
int i,j,n,t;
scanf("%d",&n);
for(i = ;i < n;i ++)
scanf("%s",str[i]);
for(i = ;i <= n;i ++)
{
for(j = ;j <= n;j ++)
{
t = str[i-][j-] == 's'?:;
r[i][j][t] = r[i-][j][t] + ;
c[i][j][t] = c[i][j-][t] + ;
r1[i][j][t] = r1[i-][j-][t] + ;
c1[i][j][t] = c1[i-][j+][t] + ;
r[i][j][t^] = ;
c[i][j][t^] = ;
r1[i][j][t^] = ;
c1[i][j][t^] = ;
}
}
int max1,max2;
max1 = max2 = ;
for(i = ;i <= n;i ++)
{
for(j = ;j <= n;j ++)
{
t = str[i-][j-] == 's'?:;
if(t)
max1 = max(max1,max(max(r[i][j][],c[i][j][]),max(r1[i][j][],c1[i][j][])));
else
max2 = max(max2,max(max(r[i][j][],c[i][j][]),max(r1[i][j][],c1[i][j][])));
}
}
if(max1 > max2)
printf("s\n%d\n",max1);
else if(max1 < max2)
printf("S\n%d\n",max2);
else
printf("?\n%d\n",max1);
return ;
}