Time of Update: 2018-12-05
題目出處:http://cs.scu.edu.cn/soj/problem.action?id=2745典型線段樹,模版題 #include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<queue>#include<vector>#include<stack>#include&
Time of Update: 2018-12-05
描述:這道題和劉汝佳書上講解的第一道例題是一樣的,完全就是用遞迴罷了,然後就是AC了……#include <iostream>#include <cstring>#include <cstdio>using namespace std;void dfs(int s[110][110],int row,int clow,int visit[110][110]){ if(!s[row][clow]||visit[row-1][clow-1])return;
Time of Update: 2018-12-05
#include<iostream>#include<string>#include<cmath>#include<algorithm>#include<cstring>#include<queue>#include<cstdio>using namespace std;const int MAXN=255;const int INF=1000000000;int
Time of Update: 2018-12-05
描述:水題,不解釋#include <cstdio>#include <cstdlib>int num_n[1000],num_m[30],count[30];int n,m,flag,sum=1;int main(){ //freopen("a.txt","r",stdin); while(scanf("%d",&n)!=EOF) { if(!n) break; for(int i=0; i<n; i++)
Time of Update: 2018-12-05
/*很經典的最大流最小割的題目題意:求最小割,但因為最小割是不唯一的,題目要求得到最小割的條件下使得割邊最少搜到usaco類似的一個題目才出的,構造很巧妙建邊的時候每條邊權 w=w*(E+1)+1;這樣得到最大流maxflow/(E+1) 就是答案了道理很簡單,如果原先兩類割邊都是最小割,那麼求出的最大流相等但邊權變換後只有邊數小的才是最小割了,至於為什麼乘的是(E+1)是為了保證邊數疊加後依然是餘數,不至於影響求最小割的結果*/#include <cstdio>#include &
Time of Update: 2018-12-05
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <set>#include<map>#include<ctime>using namespace
Time of Update: 2018-12-05
黑書上給出了關於求點割集的演算法,但是比較模糊,我查閱了網路上的相關資料,理解了求點割集的過程,寫出如下求點割集的代碼,並寫了一些簡單的證明. 割點集的定義:如果在連通圖G中去掉某一點後圖不連通,那麼這個點即為G的割點,所有割點的集合即為點割集。 求點割集的方法:利用tarjan演算法的思想,用數組dfn[v]儲存DFS遍曆到點v的時間,數組low[v]儲存點v能追溯到最早的祖先節點。如果對於點v來說有如下結論: 1.如果點v是DFS序列的根節點,則如果v有一個以上的孩子,則v是一個割點。2
Time of Update: 2018-12-05
描述:這道題就是遞迴套用遞迴,用兩個遞迴再加上一個快排就可以了AC了,但是交了一次錯誤答案,可惜了,就是在第一層遞迴的時候只要遞迴*上下前後四個方向就可以了,我遞迴成八個方向的了,-_-......#include <iostream>#include <cstring>#include <cstdio>#include <cstdlib>using namespace std;int count,visit_s[110][110];void
Time of Update: 2018-12-05
/*二維樹狀數組模版題*/#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;int c[1030][1030];int Row,Col;inline int Lowbit(const int &x){return x&(-x);}int Sum(int i,int j) //計算c[1][1]
Time of Update: 2018-12-05
#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<stack>#include<map>const int MAX_COLOUMN = 16*16*16;//最多出現列數const int MAX_ROW = 16*16*16+2;//最多出現的列數 int
Time of Update: 2018-12-05
描述:輸入三個數n,m,t,尋找一堆n和m,使之和為t,如果不存在,那麼則尋找最接近(小於等於)t的數,並求出此時所包含的最多的n與m的個數和這個數與t的差值,並輸出這兩個數#include <cstdio>int main(){ // freopen("a.txt","r",stdin); int n,m,t,count,sum,flag,pos,v; while(scanf("%d %d %d",&n,&m,&t)!=EOF) {
Time of Update: 2018-12-05
/*二分圖 最大權匹配問題,題目給定條件可以看出是完備匹配;利用最小費用最大流解決X集合連源點,邊權為1,花費0Y集合連匯點,邊權為1,花費0X連Y中任意元素,邊權為1,花費為權值的相反數最後得到的最小費用就是最大權匹配*/#include <stdio.h>#include <iostream>#include <string.h>#include<queue>#include<cmath>using namespace
Time of Update: 2018-12-05
Harry Potter and the Final BattleTime Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 294 Accepted Submission(s): 97Problem DescriptionThe final battle is coming. Now Harry Potter is located at city 1,
Time of Update: 2018-12-05
Harry Potter and the Forbidden ForestTime Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 158 Accepted Submission(s): 56Problem DescriptionHarry Potter notices some Death Eaters try to slip into
Time of Update: 2018-12-05
/*題意:三種操作0 x:向容器裡加入x;1 x: 在容器內刪除x,不存在x則輸出“No Elment”2 x y:在容器中找到大於x的第y個數,沒有則輸出“Not Find”題解:
Time of Update: 2018-12-05
描述:尋找一個數,從這個數上、下、左、右四個方向尋找一堆數,使之為遞增或者遞減數列,輸出這個數列的個數#include <cstdio>#include <cstring>int n,m,t,sum;int arr[110][110],visit[110][110],num[110][110];char s[110];int max(int x,int y){ return x>y?x:y;}int dfs(int x,int y,int pos){
Time of Update: 2018-12-05
#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>const int MAXN = 109;const double eps = 1e-6;struct point{ double x,y;}p[MAXN],h[MAXN];inline double distance(const point &p1,const point &p2){
Time of Update: 2018-12-05
/*題目地址:http://poj.org/problem?id=1523題意:給你一個關係網,求其中的關節點——去掉該點後一個連通的分塊變成兩個或兩個以上。題中點的出現次序混亂,並且可能不連續,所以要為每個點建立索引,方便操作題解:tarjan演算法參看:http://blog.csdn.net/wsniyufang/article/details/6604458http://blog.csdn.net/wsniyufang/article/details/6611781dfn[v]記錄到達點
Time of Update: 2018-12-05
/*參考:http://zhyu.me/acm/zoj-1992-and-poj-1637.html題意:給出一個混合圖(有的邊有向,有的邊無向),問此圖是否存在歐拉迴路。先說說歐拉迴路吧,起點和終點相同,經過圖G的每條邊一次,且只經過一次的路徑稱為歐拉迴路。按照圖的不同分為:無向圖歐拉迴路、有向圖歐拉迴路和混合圖歐拉迴路。判斷一個圖是否存在歐拉迴路:1.無向圖:圖連通,且圖中均為偶度頂點。2.有向圖:圖連通,且圖中所有頂點出入度相等。3.混合圖:混合圖歐拉迴路的判斷是用網路流,實現方法:首先對
Time of Update: 2018-12-05
題目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3594題意:判斷給定的有向圖是否滿足 1.強連通 2 每一條邊屬於且僅屬於一個環tarjan演算法的運用,用fa[]數組記錄tarjand的搜尋路徑,當有一個點有橫向邊(指向它的祖先節點——表示有環),據fa記錄的路徑標記 除被指向的祖先外所有路徑上的點,當有某個點被記錄2次時,必然存在一條邊屬於兩個環。#include<iostream> #include<cstdio&