國慶七連測(一)cmi

2021-08-28 15:16:39 字數 711 閱讀 4083

【一句話題意】求長度為n的序列,排序的最少元素移動次數。

【分析】

轉化一下題意,由於n一定,我們轉而求最大的不移動元素個數。於是

就是lcs啊

就是lcs啊

就是lcs啊

┓( ´∀` )┏ 裸題啊。。。。

code:

#include

#include

#include

#include

using

namespace std;

const

int maxn=

2e5+

1000

;int f[maxn]

,n,cnt=0;

inline

void

read

(int

&x)while

(tmp>=

'0'&&tmp<=

'9') x=

(x<<1)

+(x<<3)

+tmp-

'0',tmp=

getchar()

;}intld

(int x)

return l;

}int

main()

printf

("%d\n"

,n-cnt)

;return0;

}

國慶七連測(一)divide

好了關於多重揹包的討論就此打住,讓我們來考慮一下正確的解法。模擬01揹包時我們轉二維空間為一維空間,我們可以利用上述定義中的f i 所存的值。重新定義f j 表示到達位置j最多還可以剩下f j 個價值為i的物品可以利用,如果不能到達就用 1表示。狀態轉移上,如果f j 原來大於 1,則賦值為a i ...

HGOI 國慶七連測 day3

講道理,真的很譴責這種掛著羊頭賣著恐龍肉的操作。標題寫著普及訓練難度結果是noi ctsc的題orz 真的爆零,我一道題都不會寫orz,出題人是江蘇高考415的dalao 題目描述 include include include include define ll long long using n...

HGOI 國慶七連測 day5

今天又是暴力的一天 天天都是暴力暴力 還能不能好好學oi了orz 我又把暴力打崩了orz我還沒有找到暴力的精髓 題目描述 include include include include include include using namespace std void fff const int n ...