博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛
阅读量:7283 次
发布时间:2019-06-30

本文共 1635 字,大约阅读时间需要 5 分钟。

Mountain Subsequences

题目描述

Coco is a beautiful ACMer girl living in a very beautiful mountain. There are many trees and flowers on the mountain, and there are many animals and birds also. Coco like the mountain so much that she now name some letter sequences as Mountain Subsequences.

 

A Mountain Subsequence is defined as following:

1. If the length of the subsequence is n, there should be a max value letter, and the subsequence should like this, a1 < ...< ai < ai+1 < Amax > aj > aj+1 > ... > an

2. It should have at least 3 elements, and in the left of the max value letter there should have at least one element, the same as in the right.

3. The value of the letter is the ASCII value.

 

Given a letter sequence, Coco wants to know how many Mountain Subsequences exist.

输入

Input contains multiple test cases.

For each case there is a number n (1<= n <= 100000) which means the length of the letter sequence in the first line, and the next line contains the letter sequence.

Please note that the letter sequence only contain lowercase letters. 

输出

For each case please output the number of the mountain subsequences module 2012.

示例输入

4abca

示例输出

4

提示

The 4 mountain subsequences are:

aba, aca, bca, abca

来源

 2013年山东省第四届ACM大学生程序设计竞赛
1 #include 
2 #include
3 #define maxn 100005 4 #define mod 2012 5 using namespace std; 6 char str[maxn]; 7 int dp[30],dl[maxn],dr[maxn],s[maxn]; 8 int main() 9 {10 int n;11 while(cin>>n)12 {13 cin>>str;14 for(int i=0;i
=0;i--)27 {28 for(int j=0;j

 

转载于:https://www.cnblogs.com/lovychen/p/4464174.html

你可能感兴趣的文章
找回Mac丢失空间
查看>>
给大家推荐一个整合了python和bash的神器,xonsh
查看>>
数据库基本操作指令总结
查看>>
一对一直播源码全套开源,二次开发有保障!
查看>>
NumPy 超详细教程(3):ndarray 的内部机理及高级迭代
查看>>
侃一侃WebSocket
查看>>
hanlp源码解析之中文分词算法
查看>>
把你的程序放到桌面——Android桌面部件Widget
查看>>
《图解HTTP》第3章_HTTP报文内的HTTP信息-思维导图
查看>>
分享一个冷门知识——文本框的选择文本在业务中的应用
查看>>
彻底理解浏览器的跨域
查看>>
1009 说反话 (20 分)
查看>>
Flutter Wrap & Chip
查看>>
Vue路由自动注入实践
查看>>
类数组转化成数组的方法
查看>>
Android屏幕适配方案
查看>>
使用Databinding轻松快速打造仿携程app筛选控件(二)
查看>>
AppCompatActivity怎么对View做的拦截
查看>>
记b站的一次react尝试
查看>>
Binder IPC
查看>>