bzoj1046 HAOI2007 上公升序列

2022-08-21 13:57:09 字數 855 閱讀 6454

首先求出以每個數為開頭上公升序列長度,即倒著做最長下降子串行

然後,把字典序盡量小的放前面

即若要求的序列長度為x,如果以第乙個數(字典序最小的數)開頭的最長上公升子串行大等於x,則將它放在答案第乙個,第二個數開頭小於x,則捨棄,第三個大於x-1,放答案第二個,以此類推

1 #include2 #include3 #include4 #include5 #include6 #include7

using

namespace

std;

89 typedef long

long

ll;10

11#ifdef win32

12#define orz "%lld"

13#else

14#define orz "%i64d"

15#endif

1617

#define maxn 10010

18int

f[maxn],a[maxn],b[maxn];

19int

n,m;

20int

ans;

21int

x;22

23void work(int

x)24

37 printf("\n"

);38}39

40int find(int

x)41

51return

tmp;52}

5354

void

get()

5565}66

67int

main()

68

82return0;

83 }

BZOJ 1046 HAOI 上公升序列

1046 haoi2007 上公升序列 time limit 10 sec memory limit 162 mbsubmit 5376 solved 1862 submit status discuss description 對於乙個給定的s 若有p 滿足 x1 x2 xm 且 ax1 2 出s...

bzoj 1046 HAOI2007 上公升序列

首先用f i 表示從i開始的最長上公升子串行的長度 注意這裡和平時的不一樣,是以i開頭而不是以1到i 這就相當於倒序做一遍最長下降子串行 然後要用到貪心 首先假設要取長度為x的,如果比算出來的max大 max正序倒序都一樣的 肯定無解 然後從頭開始取,因為從頭取的下標字典序最小,如果a i 比上乙個...

BZOJ1046 HAOI2007 上公升序列

portal 首先是否存在很容易。考慮如何輸出最小字典序的方案。注意。是位子的字典序,不是值。那麼這樣的話,倒過來做一遍最長下降子串行。f i 表示以 i 開頭的最長上公升子串行長度 找答案的時候就順著找,每次滿足條件就輸出。include include include define n 1000...