原创 poj 4084:拓撲排序

#include<iostream> #include<cstring> using namespace std; struct node { int farNum; int sonNum; int son[110]; }; n

原创 poj 3858: 和數

#include<iostream> #include<cstring> using namespace std; int main() { int m,n; int s[110],v[110]; cin>>m; while(m-

原创 poj 3866: Red and Black

解題思路: BFS #include<iostream> using namespace std; char map[25][25]; struct node { int x,y; }; node queue[800]; int m

原创 poj 3711: 字符串移位包含問題

解題思路: (1)字符串處理 (2)string性質的應用 (3)兩個字符串都可能是子串 #include<iostream> #include<cstring> using namespace std; int main() { in

原创 poj 1088: 滑雪

解題思路: 動態規劃 #include<iostream> #include<cstdlib> using namespace std; struct area { int x,y,h; int an; }; int cmp(co

原创 poj 4002:誰是你的潛在朋友

#include<iostream> using namespace std; int main() { int m,n; int num[210]; cin>>m>>n; for(int i=1;i<=m;i++) { c

原创 poj 1828:Monkeys' Pride

解題思路: (1)快速排序,x升序,y升序 (2)倒序遍歷 #include<iostream> #include<cstdio> #include<cstdlib> using namespace std; struct monkey

原创 poj 3251: 最少費用

動態規劃 #include<iostream> using namespace std; const int inf = 0x7fffffff; int main() { int n; int map[110][110]; in

原创 poj 4087: 數據篩選

解題思路: 此題容易超內存,所以開大小爲2k的數組,每次將數組填滿(m>2k時),快排,將最小的前k個數維持在前k個位置; 將剩餘的數據陸續填充到後k個位置,重複上述操作。 #include<iostream> #include<cstd

原创 poj 2747: 數字方格

#include<iostream> using namespace std; int main() { int m,n; cin>>m; while(m--) { cin>>n; int s = 0; for(int

原创 poj 2253:Frogger

解題思路: floyd算法 #include<iostream> #include<cstring> #include<cmath> #include<iomanip> using namespace std; struct stone

原创 poj 2295: A DP Problem

解題思路: (1)字符串處理問題 (2)注意結果向下取整 #include<iostream> #include<cstring> #include<cstdlib> #include<iomanip> #include<cmath> u

原创 poj 2942: 吃糖果

#include<iostream> using namespace std; int main() { int a[25]; a[1] = 1; a[2] = 2; int n; cin>>n; if(n==1) cou

原创 poj 1164:The Castle

解題思路: (1)BFS (2)注意“重複訪問的問題” #include<iostream> #include<cstring> using namespace std; int m,n; int map[60][60]; int vi

原创 poj 2823:Sliding Window

解題思路: 單調隊列 參考:http://blog.csdn.net/heart_dash/article/details/7786258 #include<iostream> using namespace std; int a[10