跳到主要內容

發表文章

目前顯示的是 12月, 2013的文章

uva 10317

暴力剪枝就對了   一開始dfs弄錯了吃了WA,剪枝沒剪好TLE 最後終於AC了 /* * GCA : "Computer is artificial subject absolutely,Math is God" */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #define Set(a,s) memset(a,s, sizeof (a)) #define Pln() printf( "\n" ) #define For(i,x) for ( int i=0;i<x;i++) #define CON(x,y) x##y #define M 20 #define PB push_back #define oo INT_MAX #define FOR(a,b) for (VAR(a,(b).begin());a!=(

uva 11615

題目意思太坑了,一開始完全看不懂意思 結果竟然是水題 /* * GCA : "Computer is artificial subject absolutely,Math is God" */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #define Set(a,s) memset(a,s, sizeof (a)) #define Pln() printf( "\n" ) #define For(i,x) for ( int i=0;i<x;i++) #define CON(x,y) x##y #define M 31 #define PB push_back #define oo INT_MAX #define FOR(a,b) for (VAR(a,(b).begin());a!=(b).end();++a) #d

uva 866

此題用模板即可,因為不會有連到端點的線,所以也就不會有剛好三條線相交在同一點的情況 /* * GCA : "Computer is artificial subject absolutely,Math is God" */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #define Set(a,s) memset(a,s, sizeof (a)) #define Pln() printf( "\n" ) #define For(i,x) for ( int i=0;i<x;i++) #define CON(x,y) x##y #define M 100005 #define PB push_back #define oo INT_MAX #define FOR(a,b) for (VAR(a,(b).begin());a!

Codeforces Round #219 (Div. 2) D. Counting Rectangles is Fun

網路上大家都說先預處理,重點是要怎麼預處理才是重點阿 我不會啊~~~   不過在此終於懂了一些     1.先算出每一個單元格跟他上面的單元格能夠構出幾個矩形,遇到1就要變成0   2.然後再利用四個方向大枚舉u,l,d,r 利用右下角的點算出最多能夠與這四個方向以內的單元格構出多少個矩形 所以只要利用剛剛第一步驟算好的點 加上當前最小值,遇到0就不要再算了 3.加上u,l,d-1,r  u,l,d,r-1 的個數,當然 這些已經處理過了(而這些處理過的點 需要處理的點也都已經處理過了(DP概念)),而且因為會有重疊的部分所以必須扣掉u,l,d-1,r-1   /* * GCA : "Computer is artificial subject absolutely,Math is God" */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #d

TopCoder SRM 345 Div1 StoneGame

博弈,滿不錯的題目   重點在於當一個玩家想要轉換成贏的狀態時,另外一個玩家還會把優勢轉回來   所以不要再考慮轉成贏的狀態,只需要貪心的拿目前能夠擁有的   分成1個stone的群組跟多個stone的群組 等1個stone的群組全部都拿完時,多個stone個數全部加起來 奇偶數就可以判定整群是誰的了   當然之前所說的 當你想要改變奇偶數,對方也可以改變回來   // BEGIN CUT HERE // END CUT HERE #line 5 "GCAcode.cpp" #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include < string > #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b)

TopCoder SRM 345 DIV1 Pathfinding

滿強烈的思考題,四個象限分別考慮即可 // BEGIN CUT HERE // END CUT HERE #line 5 "GCAcode.cpp" #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include < string > #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #define Set(a,s) memset(a,s, sizeof (a))

TopCoder SRM 195 DIV2 optimalCoins

題意是說要構成1~value分別只需要一種方法去付錢 思考題,想出方法之後就可以直接秒過去了 有點類似權值   // BEGIN CUT HERE // END CUT HERE #line 5 "GCAcode.cpp" #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include < string > #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #de

TopCoder SRM 174 DIV2 ProbabilityTree

水題,只要dfs過去就秒掉了 // BEGIN CUT HERE // END CUT HERE #line 5 "GCAcode.cpp" #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include < string > #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #define Set(a,s) memset(a,s, sizeof (a)) #def

TopCoder SRM 196 DIV2 WaterLevel

很機車的實作題,這種題目就是要面面俱到,把所有的情況用if表達出來 // BEGIN CUT HERE // END CUT HERE #line 5 "GCAcode.cpp" #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include < string > #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> using namespace std; #ifdef DEBUG #define VAR(a,b) __typeof(b) a=(b) #define debug(...) printf( "DEBUG: " ),printf(__VA_ARGS__) #else #define VAR(a,b) __typeof(b) a=(b) #define debug(...) #endif typedef unsigned int uint ; typedef long long int Int; typedef unsigned long long int UInt; #define Set(a,s) memset(a,