HDU 5635 ——LCP Array ——————【想法题】
LCP Array
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 830 Accepted Submission(s): 232
Given the lcp array, Peter wants to know how many strings containing lowercase English letters only will satisfy the lcp array. The answer may be too large, just print it modulo 109+7.
The first line contains an integer n (2≤n≤105) -- the length of the string. The second line contains n−1 integers: a1,a2,...,an−1 (0≤ai≤n).
The sum of values of n in all test cases doesn't exceed 106.

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1e6;
const LL mod = 1000000007;
int a[maxn];
int main(){
int cas ;
scanf("%d",&cas);
while(cas--){
int n, flag = 0, c = 0;
scanf("%d",&n);
for(int i = 1; i < n; i++){
scanf("%d",&a[i]);
if(!a[i]) c++;
if(a[i] > n-i){ //限制条件
flag = 1;
}
if(a[i-1] != 0 && a[i-1] - a[i] != 1){ //减1递减
flag = 1;
}
}
if(flag){
puts("0"); continue;
}
LL ans = 26;
for(int i = 1; i <= c; i++){
ans = (ans * 25) % mod;
}
printf("%lld\n",ans);
}
return 0;
}
/*
55
5
0 1 0 4
5
0 1 0 2
4
3 2 1
5
0 1 2 0
7
0 0 3 2 1 0 */
HDU 5635 ——LCP Array ——————【想法题】的更多相关文章
- hdu 5635 LCP Array(BC第一题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5635 LCP Array Time Limit: 4000/2000 MS (Java/Others) ...
- HDU 5632 Rikka with Array [想法题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5632 ------------------------------------------------ ...
- hdu 4655 Cut Pieces(想法题)
Cut Pieces Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Tota ...
- HDU - 5806 NanoApe Loves Sequence Ⅱ 想法题
http://acm.hdu.edu.cn/showproblem.php?pid=5806 题意:给你一个n元素序列,求第k大的数大于等于m的子序列的个数. 题解:题目要求很奇怪,很多头绪但写不出, ...
- HDU 4972 Bisharp and Charizard 想法题
Bisharp and Charizard Time Limit: 1 Sec Memory Limit: 256 MB Description Dragon is watching NBA. He ...
- LCP Array(思维)
LCP Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- CodeForces 111B - Petya and Divisors 统计..想法题
找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题.... Program ...
- hdu-5635 LCP Array
LCP Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- HDU - 5969 最大的位或 想法题
http://acm.hdu.edu.cn/showproblem.php?pid=5969 (合肥)区域赛签到题...orz 题意:给你l,r,求x|y的max,x,y满足l<=x<=y ...
随机推荐
- 【转载】C# DataGridView 通过代码设置样式
// 表格上下左右自适应 dataGridView.Anchor = (AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | An ...
- 【EfF】 贪婪加载和延迟加载 (virtual去掉关闭延迟加载)
EntityFramework(EF)贪婪加载和延迟加载的选择和使用 贪婪加载:顾名思议就是把所有要加载的东西一 次性读取 1 using (var context = new MyDbContext ...
- C# 由范式编程==运算符引发对string内存分配的思考
今天在看C#编程指南时(类型参数的约束http://msdn.microsoft.com/zh-cn/library/d5x73970.aspx)看到一段描述: 在应用 where T : class ...
- ubuntu14.04,安装Gnome 15.10 (桌面)
Linux:ubuntu14.04 Gnome:15.10 更新最新版Gnome的一个好处:更新了ubuntu的软件源,我们可以使用ubuntu的软件中心获取更多需要的软件!! ubuntu默认的桌面 ...
- Mysql数据库自动定时备份软件推荐--MySqlBackupFTP(免费,亲测可用,附使用图示)
MySqlBackupFTP是一款Mysql数据库自动定时备份软件,免费版本就基本上可以满足我们的需求,不需要什么破解版,可直接官网下载安装使用. 先看结果(日志): 软件界面: 可以设定计划任务,每 ...
- centos7 docker 安装 mysql5.7.24 导入12G的sql
先在CentOS7里面安装docker Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker .通过 uname - ...
- 【离散数学】 SDUT OJ 偏序关系
偏序关系 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description 给定有限集上二元关系的关系矩 ...
- mysql数据库怎么使用,mysql的使用方法
https://jingyan.baidu.com/article/5d368d1ec069c13f61c05742.html 数据库的开启与关闭: https://blog.csdn.net/u01 ...
- Python web前端 03 CSS属性
Python web前端 03 CSS属性 一.文字.文本属性 1.文字属性 font-family #字体类型浏览器默认的字体是微软雅黑,字体中有多个字体的时候,如果前面的字体没有就使用后面的字体 ...
- Codeforces - 617E 年轻人的第一道莫队·改
题意:给出\(n,m,k,a[1...n]\),对于每次询问,求\([l,r]\)中\(a[i] \ xor \ a[i+1] \ xor \ ...a[j],l<=i<=j<=r\ ...