码迷,mamicode.com
首页 > 其他好文 > 详细

1996: [Hnoi2010]chorus 合唱队

时间:2015-05-01 22:31:52      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

1996: [Hnoi2010]chorus 合唱队

Time Limit: 4 Sec  Memory Limit: 64 MB
Submit: 1057  Solved: 681
[Submit][Status][Discuss]

Description

技术分享

Input

技术分享

Output

技术分享

Sample Input

4
1701 1702 1703 1704

Sample Output

8

HINT

技术分享 

Source

 

 
题解:萌萌哒DP题,其实和我一开始想的暴力方法很接近,基本上就是记忆化暴力,然后转变为循环形式(HansBug:无后效性这玩意就是爽^_^),然后就只管AC啦
(PS:不过话说第一遍的记忆化暴力WA掉了是What Ghost???)
 1 /**************************************************************
 2     Problem: 1996
 3     User: HansBug
 4     Language: Pascal
 5     Result: Accepted
 6     Time:108 ms
 7     Memory:8172 kb
 8 ****************************************************************/
 9  
10 const p=19650827;
11 var
12    i,j,k,l,m,n:longint;
13    c:array[0..10000] of longint;
14    a:array[0..1005,0..1005,1..2] of longint;
15 begin
16      readln(n);
17      for i:=1 to n do
18          begin
19               read(c[i]);
20               a[i,i,0]:=1;
21          end;
22      readln;
23      for i:=n-1 downto 1 do
24          for j:=i+1 to n do
25              begin
26                   a[i,j,0]:=0;a[i,j,1]:=0;
27                   if c[i]<c[i+1] then inc(a[i,j,0],a[i+1,j,0]);
28                   if c[i]<c[j] then inc(a[i,j,0],a[i+1,j,1]);
29                   if c[j]>c[i] then inc(a[i,j,1],a[i,j-1,0]);
30                   if c[j]>c[j-1] then inc(a[i,j,1],a[i,j-1,1]);
31                   a[i,j,0]:=a[i,j,0] mod p;
32                   a[i,j,1]:=a[i,j,1] mod p;
33              end;
34      writeln((a[1,n,1]+a[1,n,0]) mod p);
35      readln;
36 end.

 

 

1996: [Hnoi2010]chorus 合唱队

标签:

原文地址:http://www.cnblogs.com/HansBug/p/4471176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!