同bzoj1068: [SCOI2007]压缩,一样的做法,思路,详解请看那篇文章
#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <stack> #include <deque> #include <queue> #include <map> #include <vector> #include <set> typedef long long LL; typedef double DB; typedef unsigned US; #define For(i, s, t) for(int i = (s); i <= (t); i++) #define Ford(i, s, t) for(int i = (s); i >= (t); i--) #define Rep(i, n) for(int i = 0; i < (n); i++) #define Repn(i, n) for(int i = ((n) - 1); i >= 0; i--) #define rep(i, s, t) for(int i = (s); i < (t); i++) #define repn(i, s, t) for(int i = ((s) - 1); i >= (t); i--) #define FU(t, c) for(__typeof((c).begin()) t = (c).begin(); t != (c).end(); t++) #define FD(t, c) for(__typeof((c).rbegin()) t = (c).rbegin(); t != (c).rend(); t--) #define pi (3.1415926535) #define mk make_pair #define sqr(x) ((x) * (x)) #define ft first #define sd second #define abs(x) ((x) > 0 ? (x) : (-(x))) #define clr(c, t) (memset((c), (t), sizeof((c)))) #define sz(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define Sma_let(x) (((x) >= 'a') && ((x) <= 'z')) #define Big_let(x) (((x) >= 'A') && ((x) <= 'Z')) #define letter(x) ((Sma_let((x))) || (Big_let((x)))) #define MIT 2147483647 #define INF 1000000000 #define MLL 1000000000000000000LL #define puf push_front #define pub push_back #define pof pop_front #define pob pop_back using namespace std; // yzx'Rp ++ inline void SETIO(string name) { string IN = name + ".in", OUT = name + ".out"; freopen(IN.c_str(), "r", stdin), freopen(OUT.c_str(), "w", stdout); } const int N = 110; int Dp[N][N]; bool Vis[N][N]; char Dat[N]; int n; inline void Input() { scanf("%s", Dat + 1), n = strlen(Dat + 1); } inline bool Match(int S, int L, int C) { if(L % C) return 0; rep(i, S + C, S + L) if(Dat[i] ^ Dat[(i - S) % C + S]) return 0; return 1; } inline int Cost(int x) { int Ret = 0; while(x) Ret++, x /= 10; return Ret; } inline int Search(int Left, int Right) { int Len = Right - Left + 1, &Ret = Dp[Left][Right]; if(Len <= 1) return 1; if(Vis[Left][Right]) return Ret; Vis[Left][Right] = 1, Ret = Len; rep(i, Left, Right) Ret = min(Ret, Search(Left, i) + Search(i + 1, Right)); rep(i, 1, Len) if(Match(Left, Len, i)) Ret = min(Ret, Search(Left, Left + i - 1) + 2 + Cost(Len / i)); return Ret; } inline void Solve() { printf("%d\n", Search(1, n)); } int main() { #ifndef ONLINE_JUDGE SETIO("1090"); #endif Input(); Solve(); return 0; }
相关推荐
八中OJ,又简作BZOJ,以原题巨多而著称,该数据为BZOJ上的1000-1109和1130-1139的测试数据节点,没有题目,有需要题目的可以到https://hydro.ac/d/bzoj/p网站查找对应的题目。
BZOJ原题-BZOJP1000-P2000的题目,下载后可以离线做题。
「BZOJ1053」反素数/「Violet5」樱花 详细题解
BZOJ原题-BZOJP3001-P4000的题目,下载后可以离线做题。
bzoj部分数据.
BZOJ3230相似子串的测试数据,希望能够帮到大家。
BZOJ网站镜像,对于经常挂掉的BZOJ真是刷题必备啊!
BZOJ平台全部代码,解压到一个文件夹在打开使用。BZOJ平台全部代码,解压到一个文件夹在打开使用。
BZOJ原题-BZOJP2001-P3000的题目,下载后可以离线做题。
BZOJ原题-BZOJP4001-P4406的题目,下载后可以离线做题。
本模板为 BZOJ3224:文艺平衡树 的源程序 含各种操作,旋转,插入,删除,求前驱,后继,查询值为x的数的排名,查询排名为k的数,求最大值,最小值……
bzoj1878数据(莫队)详细题解:http://blog.csdn.net/boyxiejunboy/article/details/50611972
BZOJ省选十连测题面,只有题面!!!!!,请自行到BZOJ上进行提交,上传目的是提供离线的一个题目
题解 , 文档 , 资料 BZOJ 泡泡堂
ZOJCH是BZOJ题库的离线版
CreationAugust 的BZOJ代码合集 【Written by CreationAugust】
#BZOJ Problem Rankrank.cpp 程序文件data.dat bzoj题库数据done.dat AC过的题,初始可以把所有A过的题粘进去,正常退出的话自动维护。black.dat 黑名单。选题时会跳过。错题、神题、没题面、不想做等等。//Thank ...
八中OJ所有题目
bzoj FFT 的模版
CTSC 2011 无穷图的桥(BZOJ 2307) 题解.ppt