原创 Hdu5671 Matrix 矩陣、行列交換+行列加值

Problem Description There is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we perform q(1≤q≤10

原创 POJ1569 Myacm Triangles 判斷點與三角形的關係

Description There has been considerable archeological work on the ancient Myacm culture. Many artifacts have been f

原创 Poj2828 Buy Tickets 線段樹、單點更新

Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and joi

原创 Hdu1754 I Hate It 線段樹、單點更新+區間最值

Problem Description 很多學校流行一種比較的習慣。老師們很喜歡詢問,從某某到某某當中,分數最高的是多少。 這讓很多學生很反感。 不管你喜不喜歡,現在需要你做的是,就是按照老師的要求,寫一個程序,模擬老師的詢問。當然,老

原创 POJ1182 食物鏈 並查集

Description 動物王國中有三類動物A,B,C,這三類動物的食物鏈構成了有趣的環形。A喫B, B喫C,C喫A。  現有N個動物,以1-N編號。每個動物都是A,B,C中的一種,但是我們並不知道它到底是哪一種。  有人用兩種說法對

原创 CodeForces429B Working out

Description Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach.

原创 URAL1009 K-based Numbers

Description Let’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based

原创 POJ2007 Scrambled Polygon 凸多邊形頂點輸出

Description A closed polygon is a figure bounded by a finite number of line segments. The intersections of the boundi

原创 POJ2492 A Bug's Life 並查集

Description Background  Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes tha

原创 POJ2349 Arctic Network Prim+堆(優先隊列)、Kruskal(並查集)

Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network

原创 CodeForces702B Powers of Two

You are given n integers a1, a2, ..., an. Find the number of pairs of inde

原创 POJ2606&1118 同直線最多點數

POJ1118 傳送門 POJ2606 傳送門 這兩道題都是要求給定n個點中,處於一條直線上的點最點有多少個。 我們可以枚舉每一個點,求出其餘點與其斜率,並排序,這樣就能解決該問題了。 列舉過的點可以不必枚舉,因爲不可能出現漏算的情況。

原创 POJ1789 Truck History Prim+堆(優先隊列)、Kruskal(並查集)

Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery,

原创 HDU1232/NYOJ608 暢通工程 並查集

Problem Description 某省調查城鎮交通狀況,得到現有城鎮道路統計表,表中列出了每條道路直接連通的城鎮。省政府“暢通工程”的目標是使全省任何兩個城鎮間都可以實現交通(但不一定有直接的道路相連,只要互相間接通過道路可達即可

原创 NYOJ55 懶省事的小明

描述       小明很想吃果子,正好果園果子熟了。在果園裏,小明已經將所有的果子打了下來,而且按果子的不同種類分成了不同的堆。小明決定把所有的果子合成一堆。 因爲小明比較懶,爲了省力氣,小明開始想點子了:   每一次合併,小明可以把