本题是个简单的区间dp
dp[l][r]=dp[l][mid]+1

最近都没时间做题了,被我妈强制喊回去,然后颓废了10天(回家也没发控制住自己= = 我的锅),计划都打乱了,本来还报名了百度之星,然后没时间参加

#include<cmath>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 5e3+5;
#define MS(x,y) memset(x,y,sizeof(x))
#define MP(x, y) make_pair(x, y)
const int INF = 0x3f3f3f3f; char s[N];
int dp[N][N];
int ans[N]; int main() {
while(~scanf("%s", s+1)) {
int n = strlen(s + 1);
memset(dp, 0, sizeof(dp));
memset(ans, 0, sizeof(ans));
for(int i = 1; i <= n; ++i) {
for(int j = 1; j+i-1 <= n; ++j) {
int l = j; int r = j+i-1;
if(l == r) dp[l][r] = 1;
else if(s[l] == s[r]) {
if(dp[l+1][r-1]) {
int tt = (l+r-1) / 2;
dp[l][r] = dp[l][tt] + 1;
} else if(l == r - 1) dp[l][r] = 2;
}
}
// for(int j = 1; j+i-1 <= n; ++j) printf("%d->%d: %d ", j,j+i-1,dp[j][j+i-1]); printf("\n");
} for(int i = 1; i <= n; ++i) {
for(int j = i; j <= n; ++j) {
ans[dp[i][j]] ++;
}
}
for(int i = n; i >= 1; --i) {
ans[i] += ans[i + 1];
} for(int i = 1; i <= n; ++i) {
if(i != 1) printf(" ");
printf("%d", ans[i]);
}
printf("\n");
}
return 0;
}

Codeforces Round #427 (Div. 2) D - Palindromic characteristics的更多相关文章

  1. CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)

    证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...

  2. CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)

    s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...

  3. Codeforces Round #427 (Div. 2) Problem D Palindromic characteristics (Codeforces 835D) - 记忆化搜索

    Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th nu ...

  4. Codeforces Round #427 (Div. 2) [ C. Star sky ] [ D. Palindromic characteristics ] [ E. The penguin's game ]

    本来准备好好打一场的,然而无奈腹痛只能带星号参加 (我才不是怕被打爆呢!) PROBLEM C - Star sky 题 OvO http://codeforces.com/contest/835/p ...

  5. Codeforces Round #427 (Div. 2)—A,B,C,D题

    A. Key races 题目链接:http://codeforces.com/contest/835/problem/A 题目意思:两个比赛打字,每个人有两个参数v和t,v秒表示他打每个字需要多久时 ...

  6. Codeforces Round #427 (Div. 2) D dp

    D. Palindromic characteristics time limit per test 3 seconds memory limit per test 256 megabytes inp ...

  7. 【Codeforces Round #427 (Div. 2) D】Palindromic characteristics

    [Link]:http://codeforces.com/contest/835/problem/D [Description] 给你一个字符串; 让你在其中找到1..k阶的回文子串; 并统计它们的数 ...

  8. Codeforces Round #540 (Div. 3) C. Palindromic Matrix 【暴力】

    任意门:http://codeforces.com/contest/1118/problem/C C. Palindromic Matrix time limit per test 2 seconds ...

  9. Codeforces Round #540 (Div. 3)--1118C - Palindromic Matrix

    https://codeforces.com/contest/1118/problem/C 在查找元素的时候,必须按4,2,1的顺序进行.因为,如果先找1,可能就把原来的4拆散了,然后再找4,就找不到 ...

随机推荐

  1. HBase 数据库检索性能优化策略--转

    https://www.ibm.com/developerworks/cn/java/j-lo-HBase/index.html HBase 数据表介绍 HBase 数据库是一个基于分布式的.面向列的 ...

  2. 洛谷 [P4016] 负载平衡问题

    贪心做法 第一眼看见觉得和均分纸牌差不多,然而因为这是环形的,并不能用均分纸牌的方法做,但是均分纸牌的思想仍然适用 首先我们假设平均数为sum1. 那么对于第1个人,我们假设他给第N个人K个糖果, 第 ...

  3. [LeetCode] 679. 24 Game(回溯法)

    传送门 Description You have 4 cards each containing a number from 1 to 9. You need to judge whether the ...

  4. 测试人员如何使用Git部署测试环境

    Git是分布式的版本控制系统. 作为一名Git的小白使用者,一开始接触很懵逼,因为总担心自己一不小心误操作影响代码仓库的代码,网络上关于Git的使用多从开发的角度,很少有人从测试的角度来介绍Git的使 ...

  5. qt 移植到开发板

    一.准备工作: 1.QT应用程序 2.工具链--->交叉工具链一安装,就会有标准的c库 3.扩展的第三方库(ARM)()触摸屏库(tslib.tar.gz) 4.QT库 二.使用交叉工具链编译t ...

  6. 使用matlab生成sine波mif文件

    使用matlab生成sine波mif文件 作者:lee神 在使用altera 的FPGA中的rom过程中常常会使用到.mif文件或.hex文件.对于初学者,无论mif还是hex都是很令人疑惑的东西,这 ...

  7. C#仪器数据文件解析-PDF文件

    不少仪器工作站输出的数据报告文件为PDF格式,PDF格式用于排版打印,但不易于数据解析,因此解析PDF数据需要首先读取到PDF文件中的文本内容,然后根据内容规则解析有意义的数据信息. C#解析PDF文 ...

  8. bzoj 3576[Hnoi2014]江南乐 sg函数+分块预处理

    3576: [Hnoi2014]江南乐 Time Limit: 30 Sec  Memory Limit: 512 MBSubmit: 1929  Solved: 686[Submit][Status ...

  9. Activt工作流数据库对应表的作用

    1.资源库流程规则表 1)       act_re_deployment 部署信息表 2)       act_re_model                流程设计模型部署表 3)       ...

  10. J2ee的13个规范

    以下来自于网络. 1.JDBC(java Database Connectivity): JDBC API为访问不同的数据库提供了一种统一的途径,就像ODBC一样,JDBC对开发者屏蔽了一些细节问题, ...