本题是个简单的区间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. MySQL索引基本应用[转]

    原文地址:http://www.php100.com/html/webkaifa/database/Mysql/2010/0409/4279.html 索引是快速搜索的关键.MySQL索引的建立对于M ...

  2. MOBA战斗服务器设计思路

    MOBA作为竞技类的游戏,游戏中实时高精度同步,或者又说延迟容错率的要求还算是比较高的一种. 如何做到这种同步机制呢? 常用的同步机制有两种类型:帧同步 / 指令同步 何谓帧同步? 保证双方客户端逻辑 ...

  3. 通过WMI获取机器信息

    PerformanceCounter的介绍就不多说了,MSDN上介绍的很详细: https://msdn.microsoft.com/zh-cn/library/system.diagnostics. ...

  4. .net 远程调试

    1.我们在调试支付接口的时候很多情况下需要请求网关等,这时候需要在服务器上进行调试 首先找到服务器上的msvsmon文件,打开运行,得到对应的端口 然后打开vs,附加进程到远程地址加上端口,然后附加w ...

  5. 一步一步配置ABP Core Template with Angular

    1.首先去https://aspnetboilerplate.com/Templates下载模板工程,按如下勾选 2.下载后打开工程如下图,并设置Web.host 作为启动项目,rebuild 还原n ...

  6. 解决PhpStorm卡顿的问题

    以前的开发一直使用phpstorm.可谓是情有独钟,但是发现随着开发phpStorm逐渐变得卡顿,也试过其他的编译器,但是都感觉没有PhpSrom好用,网上百度了一下,看到不一样的回答.只要修改两个J ...

  7. MarkDown 编辑数学公式

    1. 参考博客:http://blog.csdn.net/smstong/article/details/44340637 1 数学公式的web解决方案 在网页上显示漂亮的数学公式,是多年来数学工作者 ...

  8. System.in实现数据的键盘输入

    System.in The "standard" input stream. This stream is already open and ready to supply inp ...

  9. 脚本实现centos7修改二块网卡名称并配置ip信息

    #!/bin/bash interface1=`ls /sys/class/net|grep en|awk 'NR==1{print}'`interface2=`ls /sys/class/net|g ...

  10. Socket网络通信之数据传递

    Socket通信的步骤: 1.创建ServerSocket和Socket 2.打开连接到Socket的输入/输出流 3.按照协议对Socket进行读/写操作 4.关闭输入输出流.关闭Socket 服务 ...