2021 01 27訓練總結

2021-10-18 02:16:39 字數 3535 閱讀 4437

昨天訓練一場gym鏈結,ac了8題,還剩a,c,e,g,h。e是計算幾何,所以暫無補題計畫。

題目大意:給定乙個長度為n

nn的全排列,將其拆分為兩個上公升序列,要求這兩個上公升序列的長度差最大。如果不能拆分為兩個上公升序列,輸出−1-1

−1資料範圍:n≤5

∗105

n\le5*10^5

n≤5∗10

5題解:思維題,我們考慮拆分的序列為a,b

,a[p

osa]

a,b,a[posa]

a,b,a[

posa

]為aa

a的最後乙個元素,b[p

osb]

b[posb]

b[posb

]為bb

b的最後元素,我們寫下如下的程式。

for

(int i =

1; i <= n; i++)}

} ansmn +

=min

(posa, posb)

; ansmx +

=max

(posa, posb)

;printf

("%d\n"

, ansmx - ansmn)

;

但測試資料

7

1 2 3 7 4 5 6

會導致

a=1,2,3,7

b=4,5,6

原因就是74,5,6都可以接在1,2,3後面,而我們貪心的直接將7接在1,2,3後面了,即我們需要在a[i] > a[posa]&&(a[i] > b[posb]時進行特判,看是否後面的元素接a還是接b。如果1-a[posa]已經全部在a陣列和b陣列裡面了,說明後面的元素與前面的元素相當於沒關係的兩段。我們可以遞迴的解決這個問題,具體還是看**吧。

ac**:

#include

#define ld long double

#define ll long long

using

namespace std;

template

<

class

t>

void

read

(t& x)

while

(isdigit

(c))

x = res * f;

}const ll n =

500000+10

;const

int mod =

1e9+7;

int n, a[n]

;int a[n]

, b[n]

,sum[n]

;int ansmn, ansmx;

void

add(

int x)

intquery

(int x)

void

find

(int st)}if

(a[i]

> a[posa]

)a[++posa]

= a[i]

;else

}add

(a[i]);

} ansmn +

=min

(posa, posb)

; ansmx +

=max

(posa, posb);}

intmain()

題目大意:待補

資料範圍:待補

題解:待補

ac**:

題目大意:n

nn個串,q

qq次詢問,每次詢問給出l,r

l,rl,

r兩個串,詢問n

nn個串中有多少個串滿足以l

ll為字首oror

or以r

rr為字尾

資料範圍:串長加起來不超過1e5

1e51e

5題解:我們將查詢離線,然後用兩個字典樹來儲存l

il_i

li​和r

ir_i

ri​,然後將n

nn個原串丟進去查詢即可,具體看下**。

ac**:

#pragma g++ optimize(2)

#include

#define ld long double

#define ll long long

using

namespace std;

template

<

class

t>

void

read

(t& x)

while

(isdigit

(c))

x = res * f;

}const ll n =

400000+10

;const

int mod =

1e9+7;

int n,q,ans[n]

;string s[n]

,l,r;

mapint>pre,suf,cnt;

struct trie

id[now]

.push_back

(idt);}

vector<

int>

query

(string& s)

return ans;

}}triepre,triesuf;

bool vis[n]

;void

find

(string s,

int num)

}reverse

(s.begin()

, s.

end())

; pans = triesuf.

query

(s);

for(

auto it : pans)

}for

(auto it : anss)vis[it]=0

;}intmain()

read

(q);

for(

int i =

1; i <= q; i++

)for

(auto it : cnt)

find

(it.first, it.second)

;for

(int i =

1; i <= q; i++

)return0;

}

題目大意:待補

資料範圍:待補

題解:待補

ac**:

暑假訓練總結 SSL暑假訓練總結

第一周過的還算好吧,覺得飯堂伙食也挺好的,同學也挺好。學習的東西感覺比小學難好多,有種覺得以前學的東西太簡單了的感覺,但多虧了小學的時候基礎打得還算紮實,學得還行,但總是感覺自己就是個菜雞,就是乙個蒟蒻,哎,室友真的太強了。第一周總結 第二週自我感覺挺不錯的,總算追上了部分室友,成績也開始 這一切都...

拓展訓練總結

拓展訓練總結 2006年4月30日至5月1日,我參加人眾人公司的 團隊協作 拓展訓練,在拓展訓練結束之後,雖然是身心俱疲,但感想頗多,特總結如下 一 關於拓展訓練 拓展是近年頗流行的時尚休閒方式,在教練的介紹下,我才知道它的由來 拓展英文為 outward development 中文譯為 拓展 或...

2017 1 13訓練總結

problem 0 給出乙個長度為n的序列a 1.n 將其變成序列b 1.n 的代價為 n i 1 a i b i 要使b 1.n 成為乙個不下降序列,問最小的代價 1 n 104 solution 這道題和之前做過的一道題很像,我的做法是用splay維護dp的陣列,打了二十多分鐘,還挺順的。pro...