"Bc#24 1002 hdoj 5273" Dylans loves sequence
Reverse to the game when all kinds of wonderful poses are on the merger also suppressed out of who know to show me this .... After the game some ideas received after the game of inspiration Dp[l][r] is l~r between the reverse
First the violence to enumerate the dp[1][1~n] and I from the 2~n enumeration left boundary right boundary from I+1~n so dp[i][j] that the interval left endpoint from 2 back all the inverse logarithm
and Dp[i][j] that is dp[i-1][j] in the i-1 of the reverse logarithm minus the remainder such order of violence can be ... Still looking at the brain, tot.
The code is as follows
#include <cstdio>using namespace STD;intdp[1111][1111];intnum[1111];intcnt[1111];intMain () {intI,n,q,j,l,r;scanf("%d%d", &n,&q); for(i =1; I <= N; ++i)scanf("%d", &num[i]); dp[1][1] =0; for(i =2; I <= N; ++i) {dp[1][i] = dp[1][i-1]; for(j =1; J < I; ++J) {if(Num[j] > Num[i]) dp[1][i]++; } } for(i =2; I < n; ++i) {cnt[i-1] = Num[i] < num[i-1]?1:0; for(j = i+1; J <= N; ++J) {if(num[i-1] > Num[j]) cnt[i-1]++; DP[I][J] = dp[i-1][J]-cnt[i-1]; } } while(q--) {scanf("%d%d", &l,&r);printf("%d\n", Dp[l][r]); }return 0;}
"Bc#24 1002 hdoj 5273" Dylans loves sequence