HDOJ 2859 Phalanx
来源:互联网 发布:python 金融量化分析 编辑:程序博客网 时间:2024/06/07 04:57
题意:给出一个矩阵,求其中的最大对称子矩阵
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859
思路:基础dp,从前一个子矩阵上转移,判断当前矩阵是否最大
注意点:无
以下为AC代码:
Run IDSubmit TimeJudge StatusPro.IDExe.TimeExe.MemoryCode Len.LanguageAuthor136883652015-05-13 22:24:42Accepted28592605MS6492K3270 BG++luminous11#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <iostream>#include <cstring>#include <cstdio>#include <string>#include <vector>#include <deque>#include <list>#include <map>#include <set>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <cctype>#include <climits>#include <iomanip>#include <cstdlib>#include <algorithm>//#include <unordered_map>//#include <unordered_set>#define ll long long#define ull unsigned long long#define all(x) (x).begin(), (x).end()#define clr(a, v) memset( a , v , sizeof(a) )#define pb push_back#define RDI(a) scanf ( "%d", &a )#define RDII(a, b) scanf ( "%d%d", &a, &b )#define RDIII(a, b, c) scanf ( "%d%d%d", &a, &b, &c )#define RS(s) scanf ( "%s", s )#define PI(a) printf ( "%d", a )#define PIL(a) printf ( "%d\n", a )#define PII(a,b) printf ( "%d %d", a, b )#define PIIL(a,b) printf ( "%d %d\n", a, b )#define PIII(a,b,c) printf ( "%d %d %d", a, b, c )#define PIIIL(a,b,c) printf ( "%d %d %d\n", a, b, c )#define PL() printf ( "\n" )#define PSL(s) printf ( "%s\n", s )#define rep(i,m,n) for ( int i = m; i < n; i ++ )#define REP(i,m,n) for ( int i = m; i <= n; i ++ )#define dep(i,m,n) for ( int i = m; i > n; i -- )#define DEP(i,m,n) for ( int i = m; i >= n; i -- )#define repi(i,m,n,k) for ( int i = m; i < n; i += k )#define REPI(i,m,n,k) for ( int i = m; i <= n; i += k )#define depi(i,m,n,k) for ( int i = m; i > n; i += k )#define DEPI(i,m,n,k) for ( int i = m; i >= n; i -= k )#define READ(f) freopen(f, "r", stdin)#define WRITE(f) freopen(f, "w", stdout)using namespace std;const double pi = acos(-1);template <class T>inline bool RD ( T &ret ){ char c; int sgn; if ( c = getchar(), c ==EOF )return 0; //EOF while ( c != '-' && ( c < '0' || c > '9' ) ) c = getchar(); sgn = ( c == '-' ) ? -1 : 1; ret = ( c == '-' ) ? 0 : ( c - '0' ); while ( c = getchar() , c >= '0' && c <= '9' ) ret = ret * 10 + ( c - '0' ); ret *= sgn; return 1;}inline void PD ( int x ){ if ( x > 9 ) PD ( x / 10 ); putchar ( x % 10 + '0' );}const double eps = 1e-10;const int dir[4][2] = { 1,0, -1,0, 0,1, 0,-1 };struct node{ int x, y, cnt; node(){} node( int _x, int _y ) : x(_x), y(_y) {} node( int _x, int _y, int _cnt ) : x(_x), y(_y), cnt(_cnt) {}};int n;char str[1005][1005];int dp[10005][1005];int main(){ while ( RDI ( n ) && n ){ rep ( i, 0, n ){ RS ( str[i] ); } int ans = 1; rep ( i, 0, n ){ rep ( j, 0, n ){ if ( i == 0 || j == n - 1 ){ dp[i][j] = 1; continue; } int t1 = i; int t2 = j; while ( t1 >= 0 && t2 < n && str[t1][j] == str[i][t2] ){ t1 --; t2 ++; } t1 = i - t1; if ( t1 >= dp[i-1][j+1] + 1 )dp[i][j] = dp[i-1][j+1] + 1; else dp[i][j] = t1; ans = max ( ans, dp[i][j] ); } } PIL ( ans ); } return 0;}
0 0
- HDOJ 2859 Phalanx
- HDOJ 2859 Phalanx (基础DP)
- hdu 2859 Phalanx
- HDU 2859 Phalanx
- HDU - 2859 Phalanx
- 【DP】 HDU 2859 Phalanx
- hdu-2859 Phalanx 【dp】
- HDU 2859 Phalanx
- DP-HDU-2859-Phalanx
- HDU 2859 Phalanx
- HDU 2859 Phalanx
- HDU 2859 Phalanx
- HDU 2859 Phalanx
- HDU 2859 Phalanx
- Hdu 2859 Phalanx
- 【HDU】2859 Phalanx (DP)
- Q - Phalanx HDU 2859 ( dp )
- HDU 2859 Phalanx 简单DP
- 计算机为什么能实现软关机??? 软关机设计到哪些技术??? 指令??? 电路??
- 在使用jxl时启动Tomcat报错:NoClassDefFoundError: jxl/write/WriteException
- how did this thing go
- js 高效编程 连载
- Git的深入理解与GitHub托管服务的使用
- HDOJ 2859 Phalanx
- [JSP]JSP内置对象(2)
- 关于ssh框架,hql语句直接插入当前时间的问题
- 一种定位内存泄露的方法(Linux)
- 记自己独立完成项目(取得进展)
- Android访问网络,使用HttpURLConnection还是HttpClient?
- 黑马程序员——面向对象——多态-抽象类-接口
- 5.13viewPager&&viewFlipper
- 有关fstream::read()读取错误问题