原创 codeforce #329div2 B. Anton and Lines

B. Anton and Lines time limit per test1 second memory limit per test256 megabytes inputstandard input outputstan

原创 codeforces#337 D. Vika and Segments

D. Vika and Segments(離散+掃描+線段數) time limit per test2 seconds memory limit per test256 m

原创 線段樹(2)區間修改

線段樹(2)區間修改 快速序列操作I,給出一個n個元素的數組A1,A2,…,An,你的任務是設計一個數據結構支持一下兩種操作 set(L, R, v): 把AL,AL+1,…,Ar的值全部修改爲v(v>=0) Query(L,

原创 sicily1001 全排列(升序)

sicily1001 全排列(升序) 輸入一個數字n,輸出從1~n組成的數字的全排列,每個排列佔一行,輸出按照數值升序排列 比如輸入2,則輸出是: 12 21 又如輸入3,則輸出是: 123 132 213 231 312 321

原创 [leetcode#4]Longest Common Prefix

Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. 找最長公共字

原创 範圍最小值問題 (Range Minimum Query,RMQ)

範圍最小值問題 (Range Minimum Query,RMQ) 給出一個n個元素的數組A1,A2,…,An 設計一個數據結構,支持查詢操作Query(L,R):計算min {AL,AL+1,..AR}. 思路:令d(i,j

原创 [線段樹點修改]動態最大連續和(Ray,Pass me the Dishes, LA 3938)

[線段樹點修改]動態最大連續和(Ray,Pass me the Dishes, LA 3938) “Ray, Pass me the dishes!” After doing Ray a great favor to colle

原创 [leetcode] #141 Linked List Cycle

[leetcode] #141 Linked List Cycle Given a linked list, determine if it has a cycle in it. Follow up: Can you solve

原创 sicily1002. 放雞蛋

sicily1002. 放雞蛋 Description 把M個同樣的雞蛋放在N個同樣的籃子裏,允許有的籃子空着不放,問共有多少種不同的放法?(用K表示)5,1,1和1,5,1 是同一種分法。 請寫一個程序來輸出每一種放記雞蛋的

原创 [leetcode]#160 Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins. For example, the foll

原创 codeforces #328 C. The Big Race

C. The Big Race time limit per test1 second memory limit per test256 megabytes inputstandard input outputstanda

原创 Trie字符串(Remember the Word, LA 3942)

Trie字符串(Remember the Word, LA 3942) 給出一個由S個不同單詞組成的字典和一個長字符串。把這個字符串分解成若干個單詞的連接(單詞可重複使用),有多少種方法?比如,有4個單詞a、b、cd、ab,則ab

原创 [leetcode#6]ZigZag Conversion

[leetcode#6]ZigZag Conversion The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows

原创 LA 4513 Stammering Aliens

在這道題上學會了兩種方法解決。一種是用哈希lcp法,另一種用後綴數組求解。 Dr. Ellie Arroway has established contact with an extraterrestrial civilizat

原创 sicily1000. 整數劃分

sicily1000. 整數劃分 Description 對於一個整數m,m > 0,它可以寫成t個整數的和的形式(t>0): m = z1 + z2 + … + zt ,其中zi > 0且爲整數(1≤i≤t) 這t個整數就是整