Time of Update: 2018-12-05
這算是我實現的第一個強連通分量(scc)的題目,
Time of Update: 2018-12-05
這裡很顯然是拆點。但是在呢麼拆呢之前做的時候,是拆的牛,今天拆的食物和水,果斷錯了,按照我的建圖方法,S連牛,牛連水,水連食物,食物連E,很顯然,無法保證從牛出的到水,然後從水走出的邊無法保證是之前那個牛喜歡的食物,因此錯!正常的建圖,S連水,水連牛,牛拆點,牛連食物,食物連E!細節見代碼:#include <cstdio>#include <cstring>int N, F, D, map[500][500];const int inf = 9999999;int
Time of Update: 2018-12-05
開始在hrbust上做的,資料改為20,用矩陣和普通的最大流演算法均可以過!後來查的時候看到了hdu上的,資料比那個大很多,點數最多可達40000,第一次MLE,換成鄰接表,第二次TLE,果斷換演算法,sap輕鬆秒過!建圖的方法就是遠點連2, 終點連1,容量inf, 把每個挨著的格子連起來,容量1,求最小割!
Time of Update: 2018-12-05
把所有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],
Time of Update: 2018-12-05
// 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
Time of Update: 2018-12-05
// 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
Time of Update: 2018-12-05
// 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
Time of Update: 2018-12-05
// 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 &
Time of Update: 2018-12-05
如果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
Time of Update: 2018-12-05
裸的AC 自動機,但是題目沒有說明白啊。keyword 是可以重複的,同時也要就算這些重複的keyword,囧!而且用c++貌似會TLE。。。下面是代碼,將當做AC 自動機的模板吧,以後幾天,當然還是要多多理解AC 自動機,多敲模板了。#include<stdio.h>#include<string.h>#include<queue>#define maxs 1000050#define maxn 500050using namespace std;int
Time of Update: 2018-12-05
還是一道裸的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];
Time of Update: 2018-12-05
/* 題意 : 對於一個序列,開始嚴格上升,然後嚴格下降的最長的長度 就是最長上升子序列的變形,對於i,(從左從右)求兩次上升子序列的最長長度 ,尋找到最長的長度 */#include <cstdio>#include <vector>#include <iostream>#include <algorithm>using namespace std;const int MAX = 1000000+10;int
Time of Update: 2018-12-05
#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
Time of Update: 2018-12-05
有一段時間沒有這樣的做題了,做了一天的題。今天把樹狀數組也簡單複習了一下。今天跟著HRBUST訓練又弄了一下搜尋的相關題目,說實話,做得有些艱難。A題:
Time of Update: 2018-12-05
這道題開始的我忽略了如果它不連通的情況,判斷的時候連著入度判斷讓入度不為0,出度為1,
Time of Update: 2018-12-05
// 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
Time of Update: 2018-12-05
一定要清楚的一個問題,就是:()兩條黑色的線的和一定小於藍色的和,但是平方的和之間就不一定是這個關係了!代碼:#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <cmath>using namespace std;const double INF = 0x7fffffff;const double eps =
Time of Update: 2018-12-05
// 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////
Time of Update: 2018-12-05
取出其中的數字取出時間數:#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("
Time of Update: 2018-12-05
首先吐槽一下求面積和體積不用π。其實不減枝的代碼還是很好寫的://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