hdu 4328 Cut the cake
来源:互联网 发布:魔力视频软件下载 编辑:程序博客网 时间:2024/06/05 16:27
wa是经常的,debug需要放松和冷静,比如说这道水题我洗完澡之后直接就ac了。。。 ╮(╯▽╰)╭
#include<iostream>#include<vector>#include<algorithm>#include<cstdio>#include<queue>#include<stack>#include<string>#include<map>#include<set>#include<cmath>#include<cassert>#include<cstring>#include<iomanip>using namespace std;#ifdef _WIN32#define i64 __int64#define out64 "%I64d\n"#define in64 "%I64d"#else#define i64 long long#define out64 "%lld\n"#define in64 "%lld"#endif/************ for topcoder by zz1215 *******************/#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)#define FFF(i,a) for( int i = 0 ; i < (a) ; i ++)#define FFD(i,a,b) for( int i = (a) ; i >= (b) ; i --)#define S64(a) scanf(in64,&a)#define SS(a) scanf("%d",&a)#define LL(a) ((a)<<1)#define RR(a) (((a)<<1)+1)#define pb push_back#define CL(Q) while(!Q.empty())Q.pop()#define MM(name,what) memset(name,what,sizeof(name))#define MAX(a,b) ((a)>(b)?(a):(b))#define MIN(a,b) ((a)<(b)?(a):(b))#define read freopen("out.txt","r",stdin)#define write freopen("zz.txt","w",stdout)const int inf = 0x3f3f3f3f;const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;const double oo = 10e9;const double eps = 10e-9;const double pi = acos(-1.0);const int maxn = 1111;int hr[maxn][maxn];int hb[maxn][maxn];int h[maxn][maxn];char c[maxn][maxn];int pos[maxn];int s[maxn];int l[maxn];int n,m,cnt;int ans;void gao(int now,int x,bool w=true){if(w){while(now < s[cnt-1]){if(s[cnt-1]>0)ans = max(ans,s[cnt-1]+x-l[cnt-1]);cnt--;}s[cnt]=now;l[cnt]=pos[cnt-1]+1;pos[cnt]=x;cnt++;}else{for(int i=1;i<cnt;i++){ans = max(ans,s[i]+x-l[i]);}cnt = 1;s[cnt] = now;l[cnt] = x;pos[cnt] = x;pos[0] = x-1;l[0] = x-1;cnt++;}return ;}void find(){int temp;for(int k=1;k<=m;k++){cnt=1;s[0]=-2;pos[0]=l[0]=0;gao(h[1][k],1,true);for(int i=2;i<=n;i++){if(c[i][k]==c[i-1][k]){gao(h[i][k],i,false);}else{gao(h[i][k],i,true);}}gao(-1,n+1,true);}for(int k=1;k<=m;k++){cnt = 1;s[0]=-2;pos[0]=l[0]=0;for(int i=1;i<=n;i++){gao(hr[i][k],i);}gao(-1,n+1);}for(int k=1;k<=m;k++){cnt = 1;s[0]=-2;pos[0]=l[0]=0;for(int i=1;i<=n;i++){gao(hb[i][k],i);}gao(-1,n+1);}return ;}int lzls(){ans = 0; for(int i=1;i<=n;i++){h[i][1]=1;}for(int i=1;i<=n;i++){for(int j=2;j<=m;j++){if(c[i][j]==c[i][j-1]){h[i][j]=1;}else{h[i][j]=h[i][j-1]+1;}}}for(int i=1;i<=n;i++){hr[i][0]=0;hb[i][0]=0;}for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){if(c[i][j]=='R'){hr[i][j]=hr[i][j-1]+1;hb[i][j]=0;}else{hb[i][j]=hb[i][j-1]+1;hr[i][j]=0;}}}find();return ans;}int main(){int T;cin>>T;for(int tt=1;tt<=T;tt++){cin>>n>>m;for(int i=1;i<=n;i++){cin>>c[i]+1;}int temp = lzls()*2;cout<<"Case #"<<tt<<": "<<temp<<endl;}return 0;}
- HDU 4328 - Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- HDU-4328-Cut the cake
- HDU 4328 Cut the cake
- hdu - 4328 - Cut the cake - dp
- [HDU 4328] Cut the cake (悬链法)
- HDU 4762 Cut the Cake
- HDU-4762 Cut the Cake
- hdu 4328 cut the cake#单调队列#DP
- HDU 4328 Cut the Cake(动态规划)
- hdu 4328 Cut the cake 最大子矩阵
- HDU 4328 Cut the cake 最大相同子矩阵, 悬线法
- HDU 4328 Cut the cake(最大子矩阵+悬线法)
- hdu 4762 - Cut the Cake(大数)
- hdu 4762 Cut the Cake(高精度&概率)
- hdu 4762 Cut the Cake(高精度)
- migrator
- Canny Edge Detector
- 为Android系统定制重启功能
- 叉积+二分:Toy Storage
- Geometric Scaling
- hdu 4328 Cut the cake
- “[]”运算符的重载
- Laplacian of Gaussian
- Fourier Transform
- T-SQL 数字位位数求和
- RotateRotate Common Names: Rotation Brief Description The rotation operator performs a geometric
- 求正数数组的子数组之和等于给定值
- VS2010环境变量的配置
- hdu 4327 简单立体几何 + 半平面交