Time of Update: 2018-12-03
簡單的並查集小題。再過兩周就NOIP複賽了...原來什麼題都有0ms過的牛人!我的解法15ms/* * HDU-1232 暢道工程 * mike-w * 2011-10-21 * --------------- * tag: MST? 並查集... */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 1111int set[SIZE];int mkset(int n){int
Time of Update: 2018-12-03
準備睡覺,明天還得起早上學:(/* * HDU-1874 暢道工程續 * mike-w * 2011-8-23 *---------------------- * practice dijkstra */#include<stdio.h>#define SIZE 222#define INF (1<<30)long road[SIZE][SIZE];long dist[SIZE];int in[SIZE];int N,M;int S,T;int extract(void)
Time of Update: 2018-12-03
最短路徑的水題,不過我貢獻了若干個WA,只因為題目裡M,N坑爹的含義沒仔細看——通常N是結點個數……,於是我代碼中的一個字母錯了,然後就悲劇了……PS 我之所以把抽取最小值的ex_min()單拿出來是因為這樣容易用堆最佳化。/* * hdu-1863 * mike-w * 2012-4-13 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 128#define
Time of Update: 2018-12-03
ZOJ Problem Set - 1530Find The Multiple Time Limit: 1 Second Memory Limit: 32768 KB Special Judge Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0
Time of Update: 2018-12-03
這道題搞了一下午。。。這道題是DFS+一點小計倆,因為要判重。DFS容易辦,判重不大容易。SOLUTION 1:將所有的解都存起來,然後排序,剔除重複的,輸出。此法比較麻煩,況且超不逾時還不一定。SOLUTION 2:依舊是蠻力法,只不過是在輸出解得時候檢查是否先前已經輸出過。SOLUTION 3:這才是聰明的辦法,不是我原創,原創者的確有才!!!先看一組資料4 6 4 3 2 2 1
Time of Update: 2018-12-03
這是我第三遍做這個題,這次用了二元堆積,速度可以進GCC的第一頁。C語言提交的選項對ANSI C支援的不是很好。/* * HDU-1233 還是暢道工程 * mike-w * 2011-8-17 * -------------------- * 二元堆積實現PRIM */#include<stdio.h>#include<Stdlib.h>#include<string.h>#define MAXN 200#define HEAP_SIZE
Time of Update: 2018-12-03
此題本人的解法速度不錯,在STATISTICS中的第一頁 /* * hdu-2757 ocean currents * mike-w * 2012-3-17 * **************************************** * 通過此題,學習了邊權只含0,1的圖的 * 最短路的求法 * **************************************** * 速度很快!小得意一下
Time of Update: 2018-12-03
最近學習DP,做到最長XX序列的nlogn演算法時,感到十分糾結。上網看了諸多文章,發現其實都是“互相借鑒”。 為了搞懂,我花了好幾天,主要研究二分怎麼寫,最後總算大徹大悟了! 以下代碼是NOIP攔截飛彈的代碼,求XX序列的模組我寫成了函數,並且添加了詳細的注釋。 creativewang原創,轉載請寫出處。不要把我名字和EMAIL刪掉==|| /**最長XX序列,nlogn實現。C語言。email:creativewang@163.com**/#include<stdio.h>#d
Time of Update: 2018-12-03
如何求樹的直徑我就不說了。AC此題後有兩點感悟:1. 通過邊集來儲存圖(如何尋找) 2. 先想清楚再編碼,否則會一塌糊塗/* * POJ-2631 * mike-w * 2012-10-10 * ****************************** * find the diameter of a tree */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAXSIZE 11
Time of Update: 2018-12-03
要代碼的封裝性=> 犧牲了效率 /* * 第一次用模板寫高精度 */#include<stdio.h>#include<stdlib.h>#include<string.h>#include<assert.h>#define BASE 10000#define WIDTH 4#define MAXLEN 50000typedef struct _lnum{long num[MAXLEN];int len;}lnum;int
Time of Update: 2018-12-03
入門題目。。。/* * hdu-2688 rotate * mike-w * 2011-11-30 * ---------------------- * tag: * 數狀數組 * ps: *講述一下我做這道題的悲慘遭遇: *1. 提交別人的代碼,發現都是TLE... *2. 看別人風格糟糕的代碼時被忽悠了: :??::?? <-為啥不if-then?! *3. 貢獻WA+TLE 二十多個==|| *4. 這道題竟然卡輸入!!! * tip: * 做題時自己要想明白,然後再寫代碼。 */#
Time of Update: 2018-12-03
LIS有N2的演算法,還有NLOGN的演算法,這裡說一下NLOGN的演算法。我們設S[]為原始序列,F[i]為以S[i]結束的LIS的最大長度。在求LIS時,對於S[i],我們找一個最大的可能的F[j],(j<i)使S[i]儘可能大,在尋找一個F[i]時,我們可以用二分尋找最佳化。我們要通過枚舉F[1...i-1]找到可作為F[i]首碼的LIS的最大長度,換一種思路,我們就可以枚舉可能的長度——用二分——再檢查它是否可以串連在S[i]的前面。於是我們用C[i]記錄長度為i的LIS的末位的最
Time of Update: 2018-12-03
ZOJ Problem Set - 1091Knight Moves Time Limit: 1 Second Memory Limit: 32768 KB A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a
Time of Update: 2018-12-03
我需要逐漸提高自己實現代碼的能力。93ms,希望知道更快的解法。/* * hdu-1063 exponantaion * mike-w * 2012-5-24 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_NUM_LEN 150#define min(a,b) ((a)<(b)?(a):(b))#define NMIKE_DEBUGtypedef struct
Time of Update: 2018-12-03
參考題解之後,AC!算是NOIP2011後的線段樹第一題!逆序對數——經典問題吧。逆序對數有一個性質,見DISCUSS。統計某一個區間的元素個數,當然線段樹!/* * hdu-1394 minimum inversion number * mike-w * 2011-11-25 * --------------------------------- * reckon with this: * contains a permutation of the n integers from 0 to
Time of Update: 2018-12-03
原文連結:http://blog.sina.com.cn/s/blog_5e1ec7060101c4m7.html201305028收藏由於WinRAR支援7z壓縮包的解壓,但並不支援7z分卷檔案的解壓,若直接用WinRAR開啟7z分卷檔案時會報錯。 原因是7z的分卷檔案其實是把一個大的,例如ABC.7z檔案,直接切割成多個分卷檔案:ABC.7z.001ABC.7z.002...ABC.7z.010 可以先用DOS中的copy命令將分卷檔案合并,再解壓即可。方法是進入DOS,
Time of Update: 2018-12-03
作此題蓋練習BST,在調試的過程領會了C指標的博大精深,稍不注意就錯,怪不得C++有傳引用的特性(VB也有)鄙人BST動態分配記憶體,易錯啊!!!小盆友謹慎模仿 CSDN的插入代碼外掛程式貌似有點問題,我的一段代碼跑到<pre>標籤外面了,還得手動改代碼.../* * ZOJ 1700 falling leaves * mike-w * 2011-08-13 * ---------------------------------------------------- *
Time of Update: 2018-12-03
ZOJ Problem Set - 1002Fire Net Time Limit: 1 Second Memory Limit: 32768 KB Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A
Time of Update: 2018-12-03
RSS新聞閱讀器的特點a. 沒有廣告或者圖片來影響標題或者文章概要的閱讀。 b. RSS閱讀器自動更新你定製的網
Time of Update: 2018-12-03
水題一道....要細心!!!/* * tyvj-p1030 乳草的入侵 * mike-w * 2011-10-26 * --------------------- * simple flood fill * 注意左下角是(1,1) * url: http://tyvj.cpwz.cn/Problem_Show.asp?id=1030 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define