1287

水DP

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define N 1402
int dp[N][N][];
char s[N][N];
int main()
{
int i,j,n;
scanf("%d",&n);
for(i = ; i < n ; i++)
cin>>s[i];
dp[][][] = ;
dp[][n-][] = ;
for(i = ; i < n ; i++)
{
dp[][i][] = ;
dp[i][][] = ;
}
for(i = ; i < n ;i++)
for(j = ; j < n ; j++)
{
if(i!=&&j!=&&s[i][j]==s[i-][j-])
{
dp[i][j][] = dp[i-][j-][]+;
}
else
dp[i][j][] = ;
if(i!=&&j!=n-&&s[i][j]==s[i-][j+])
{
dp[i][j][] = dp[i-][j+][]+;
}
else
dp[i][j][] = ;
if(j!=&&s[i][j]==s[i][j-])
{
dp[i][j][] = dp[i][j-][]+;
}
else
dp[i][j][] = ;
if(i!=&&s[i][j]==s[i-][j])
{
dp[i][j][] = dp[i-][j][]+;
}
else
dp[i][j][] = ;
}
int maxz1=,maxz2=;
for(i = ; i < n ; i++)
for(j = ; j < n ; j++)
{
int kk = max(max(dp[i][j][],dp[i][j][]),max(dp[i][j][],dp[i][j][]));
if(s[i][j]=='S')
{
if(kk>maxz1)
{
maxz1 = kk;
}
}
else if(kk>maxz2)
maxz2 = kk;
}
if(maxz1>maxz2)
{
printf("S\n");
printf("%d\n",maxz1);
}
else if(maxz1<maxz2)
{
printf("s\n");
printf("%d\n",maxz2);
}
else
{
printf("?\n");
printf("%d\n",maxz1);
}
return ;
}

1287. Mars Canals(DP)的更多相关文章

  1. 【腾讯Bugly干货分享】微信终端跨平台组件 mars 系列(一) - 高性能日志模块xlog

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57ff5932cde42f1f03de29b1 本文来源: 微信客户端开发团队 ...

  2. URAL 1287. Mars Canals

    题目链接 这题挺水,看懂了,就OK.卡了几下内存,还是卡过了. #include <iostream> #include <cstdio> #include <cstri ...

  3. MemSQL start[c]up Round 2 - online version(DP)

    只有小写字母 那>=2600的直接找单字母串长度大于等于100的就可以了 <2600 的dp找最长回文串 #include <iostream> #include<cst ...

  4. A1027 Colors in Mars (20)(20 分)

    A1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar ...

  5. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

  6. 【Python五篇慢慢弹(3)】函数修行知python

    函数修行知python 作者:白宁超 2016年10月9日21:51:52 摘要:继<快速上手学python>一文之后,笔者又将python官方文档认真学习下.官方给出的pythondoc ...

  7. Effective java笔记(五),枚举和注解

    30.用enum代替int常量 枚举类型是指由一组固定的常量组成合法值的类型.在java没有引入枚举类型前,表示枚举类型的常用方法是声明一组不同的int常量,每个类型成员一个常量,这种方法称作int枚 ...

  8. Spark入门实战系列--8.Spark MLlib(上)--机器学习及SparkMLlib简介

    [注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .机器学习概念 1.1 机器学习的定义 在维基百科上对机器学习提出以下几种定义: l“机器学 ...

  9. Spark入门实战系列--8.Spark MLlib(下)--机器学习库SparkMLlib实战

    [注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .MLlib实例 1.1 聚类实例 1.1.1 算法说明 聚类(Cluster analys ...

随机推荐

  1. Spiral Matrix II

    Spiral Matrix II Given an integer n, generate a square matrix filled with elements from 1 to n2 in s ...

  2. 在myeclipse中使用Java语言进行spark Standalone模式应用程序开发

    一.环境配置 Myeclipse中虽然已经集成了maven插件,但是由于这个插件版本较低,建立maven project会出现错误. 解决办法:自己到官网http://maven.apache.org ...

  3. isEmpty()与equals()、==“”区别

    isEmpty方法源码:public static boolean isEmpty(String str) { return (str == null) || (str.length() == 0); ...

  4. The 10th Zhejiang Provincial Collegiate Programming Contest

    Applications http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5008 string set 专场 #include& ...

  5. [设计模式] 21 策略模式 Strategy

    在GOF的<设计模式:可复用面向对象软件的基础>一书中对策略模式是这样说的:定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换.该模式使得算法可独立于使用它的客户而变化. 策略模 ...

  6. hdu 3807

    很好的思路     枚举有多少人有ipad 判是否满足题目给出的条件 #include <iostream> #include <cstring> #include <c ...

  7. model对象之setter方法使用,解决去除空格和将数字转成字符串展示方法

    1.系统中手机号注册的时候,不能含有前后空格.在model对象中过滤~! private String mobile; public String getMobile() { return mobil ...

  8. 【C++之STL】理解容器(ing)

    “容器可容纳一些数据的模板类” “容器是包容其他对象的对象” 两种类型:顺序容器.关联容器   顺序容器 关联容器 访问成员 顺序访问和随机访问 经过优化关键键值访问                 ...

  9. POJ 2499 Binary Tree(二叉树,找规律)

    题意:给一个这样的二叉树,每个节点用一对数(a,b)表示,根节点为(1,1).设父亲为(a,b),左儿子(a+b,b),右儿子(a,a+b). 给几组数据,(i,j),求从根节点到(i,j)节点需要向 ...

  10. POJ 2912 Rochambeau(难,好题,枚举+带权并查集)

    下面的是从该网站上copy过来的,稍微改了一点,给出链接:http://hi.baidu.com/nondes/item/26dd0f1a02b1e0ef5f53b1c7 题意:有N个人玩剪刀石头布, ...