poj1236 Network of School ( tarjian + 縮點 )

這算是我實現的第一個強連通分量(scc)的題目,

poj 3281 dining( 最大流 )

這裡很顯然是拆點。但是在呢麼拆呢之前做的時候,是拆的牛,今天拆的食物和水,果斷錯了,按照我的建圖方法,S連牛,牛連水,水連食物,食物連E,很顯然,無法保證從牛出的到水,然後從水走出的邊無法保證是之前那個牛喜歡的食物,因此錯!正常的建圖,S連水,水連牛,牛拆點,牛連食物,食物連E!細節見代碼:#include <cstdio>#include <cstring>int N, F, D, map[500][500];const int inf = 9999999;int

hdu 3046 Pleasant sheep and big big wolf(sap最大流)

開始在hrbust上做的,資料改為20,用矩陣和普通的最大流演算法均可以過!後來查的時候看到了hdu上的,資料比那個大很多,點數最多可達40000,第一次MLE,換成鄰接表,第二次TLE,果斷換演算法,sap輕鬆秒過!建圖的方法就是遠點連2, 終點連1,容量inf, 把每個挨著的格子連起來,容量1,求最小割!

hdu 4635 Strongly connected (tarjan)

把所有scc找出來,縮點,然後在出度為0或入度為0的的塊中選擇點數最小的塊作為獨立塊,使得這一塊和其他的塊不能強連通,其餘的點都實現強連通即可!#include <cstdio>#include <vector>#include <stack>#include <cstring>using namespace std;const int N = 100010;vector <int> G[N];int pre[N],

UVa Problem 10150 Doublets (Doublets 序列)

// Doublets (Doublets 序列)// PC/UVa IDs: 110307/10150, Popularity: C, Success rate: average Level: 3// Verdict: Accepted// Submission Date: 2011-05-20// UVa Run Time: 0.200s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net//// 此題目可以轉換為求無權圖的最短路問題,可以用 BFS

UVa Problem 10132 File Fragmentation (檔案片段)

// File Fragmentation (檔案片段)// PC/UVa IDs: 110306/10132, Popularity: C, Success rate: average Level: 2// Verdict: Accepted// Submission Date: 2011-05-19// UVa Run Time: 0.012s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net#include

UVa Problem 10188 Automated Judge Script (自動評測指令碼)

// Automated Judge Script (自動評測指令碼)// PC/UVa IDs: 110305/10188, Popularity: B, Success rate: average Level: 1// Verdict: Accepted// Submission Date: 2011-05-23// UVa Run Time: 0.016s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net#include

UVa Problem 850 Crypt Kicker II (解密 II)

// Crypt Kicker II (解密 II)// PC/UVa IDs: 110304/850, Popularity: A, Success rate: average Level: 2// Verdict: Accepted// Submission Date: 2011-05-23// UVa Run Time: 0.016s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net#include <iostream>#include &

Poj 1960 Period//kmp

    如果P[1...K]與P[L-k+1...L]匹配(L為字串長度),那麼P[L-k+1...L]這一段字元一定是在重複P[1...L] - P[L-K+1...L]這段字元。    反證法:如果不是重複這一段,那麼P[1...K]與P[L-k+1...L]不可能匹配。可以畫圖試一試。    注意字串開始位置是0.下面是代碼:#include<stdio.h>#include<string.h>#define maxn 1000500char

Hdu 2222 Keywords Search//Aho-Corasick 自動機

裸的AC 自動機,但是題目沒有說明白啊。keyword 是可以重複的,同時也要就算這些重複的keyword,囧!而且用c++貌似會TLE。。。下面是代碼,將當做AC 自動機的模板吧,以後幾天,當然還是要多多理解AC 自動機,多敲模板了。#include<stdio.h>#include<string.h>#include<queue>#define maxs 1000050#define maxn 500050using namespace std;int

Hdu 2896 病毒侵襲//Aho-Corasick 自動機

  還是一道裸的AC自動機的題目,但是字元集擴大了。字元都是ASCII碼可見字元。不知道什麼是字元都是ASCII碼可見字元,所以RE了很多次,囧!  下面是代碼:#include<stdio.h>#include<string.h>#include<queue>using namespace std;const int maxn = 10005;const int maxc = 128;int ch[maxn*6][maxc];int val[maxn*6];

題目1500:出操隊形

/* 題意 : 對於一個序列,開始嚴格上升,然後嚴格下降的最長的長度 就是最長上升子序列的變形,對於i,(從左從右)求兩次上升子序列的最長長度 ,尋找到最長的長度 */#include <cstdio>#include <vector>#include <iostream>#include <algorithm>using namespace std;const int MAX = 1000000+10;int

Hoj 1005 利用矩陣計算線性遞推式

#include <stdio.h>void matrix_mul(int (*a)[2],int (*b)[2]);//a = a * bvoid matrix_matrix(int n,int (*a)[2],int (*b)[2]);int main (){ int a,b,n,fn; int f[2][2],ans[2][2]; while (1){ scanf("%d%d%d",&a,&b,&n); if (a

7-24 搜尋

有一段時間沒有這樣的做題了,做了一天的題。今天把樹狀數組也簡單複習了一下。今天跟著HRBUST訓練又弄了一下搜尋的相關題目,說實話,做得有些艱難。A題:

poj 2186 Popular cows ( tarjan )

這道題開始的我忽略了如果它不連通的情況,判斷的時候連著入度判斷讓入度不為0,出度為1,

UVa Problem 10270 Bigger Square Please… (拼接正方形)

// Bigger Square Please... (拼接正方形)// PC/UVa IDs: 110808/10270, Popularity: C, Success rate: high Level: 3// Verdict: Accepted// Submission Date: 2011-09-25// UVa Run Time: 0.032s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net//// [問題描述]// Tony

Uva live 4043 Ants( KM+簡單的計算幾何)

一定要清楚的一個問題,就是:()兩條黑色的線的和一定小於藍色的和,但是平方的和之間就不一定是這個關係了!代碼:#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <cmath>using namespace std;const double INF = 0x7fffffff;const double eps =

UVa Problem 10041 Vito’s Family (Vito 家族)

// Vito’s Family (Vito 家族)// PC/UVa IDs: 110401/10041, Popularity: A, Success rate: high Level: 1// Verdict: Accepted// Submission Date: 2011-05-21// UVa Run Time: 0.104s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net////

sscanf() 函數的應用 atoi() atof()

取出其中的數字取出時間數:#include <stdio.h>#include <stdlib.h>char *tokenstring = "12:34:56-7890";char a1[3], a2[3], a3[3];int i1, i2;void main(void){ clrscr(); sscanf(tokenstring, "%2s:%2s:%2s-%2d%2d", a1, a2, a3, &i1, &i2); printf("

Poj 1190 生日蛋糕//回溯,減枝

首先吐槽一下求面積和體積不用π。其實不減枝的代碼還是很好寫的://m為蛋糕的層數//v為當前已塗的體積//s為當前已塗得到的S//r和h為當前層的半徑和高void dfs(int m,int v,int s,int r,int h){ //推出條件 if(m == 0) { if(ans > s && v == N) ans = s; return; } //枚舉可能的解 for(int i = r-1; i

總頁數: 61357 1 .... 13459 13460 13461 13462 13463 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.