Time of Update: 2018-12-05
這道題題目沒說是多case,所以無情wa了半個多小時。囧!AC自動機的水題,下面是代碼:#include<stdio.h>#include<string.h>#include<queue>#include<ctype.h>using namespace std;#define maxn 1010*50#define maxc 26int ch[maxn][maxc];int val[maxn];int f[maxn];int cnt;int
Time of Update: 2018-12-05
裸的矩陣乘法加矩陣快速冪 下面是代碼:#include<stdio.h>#include<string.h>#define maxn 1010int A,B,n;struct node{ int m[2][2]; void init() { memset(m,0,sizeof(m)); }} a,b;node martix_mul(node a,node b){ node temp; temp.init();
Time of Update: 2018-12-05
這道題大致想法沒有問題,首先要縮點,然後重構圖,判斷重構的圖是不是弱連通。這裡有分析可知,不管圖是什麼樣的,裡面一定存在一條鏈,從入度為0的點走到出度為0的點,這一路上要包括所有的點。要想任意兩點都能弱連通,那麼必然邊的方向是一定。tarjan縮點,重構圖就不用解釋了,主要是後面怎麼判斷DAG是不是有一條鏈包括所有的點。這裡用的是dfs搜尋,查過其他牛們的部落格,還有拓撲排序(如果刪掉一個點後,新出現兩個或多個入度為的點,說明這些新出現的入度0的點都是來自刪去的點,它們之間不連通),還有就是dp
Time of Update: 2018-12-05
這道題,推一下關係式就出來了。 下面是代碼:#include<stdio.h>#include<string.h>#include<string>#include<map>using namespace std;const int maxn = 100 + 10;string s;char str[maxn];map<string,int> Map;struct node{ int m[maxn][maxn];
Time of Update: 2018-12-05
這篇解釋得比較好:
Time of Update: 2018-12-05
題目大意:人往低處滑雪,求滑雪滑出最長長度思路:d[i][j]=max{dp[i-1][j]+1,dp[i+1][j]+1,dp[i][j-1]+1,dp[i][j+1]+1},當然要滿足一些基本條件:高低. 這裡是用記憶化搜尋 AC program:#include<iostream>#include<stdio.h>#include<string.h> using namespace std;int map[105][105];int dir[4][2]
Time of Update: 2018-12-05
// Contest Scoreboard (比賽計分板)// PC/UVa IDs: 110207/10258, Popularity: B, Success rate: average Level: 1// Verdict: Accepted// Submission Date: 2011-05-23// UVa Run Time: 0.008s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net////
Time of Update: 2018-12-05
剛學html 各方面還不完善 貌似還是覺得c,c++比較簡單~~下面寫了一個顧城的小詩的html 網頁 好搓~~ 一點點成長吧~~<html><head><title>顧城-遠和近</title><head><body align = "center" style = "background-color: gray" ><p align = "center" >遠和近</p><strong &
Time of Update: 2018-12-05
Problem GDoves and BombsInput: Standard InputOutput: Standard Output Time Limit: 2 SecondsIt is the year 95 ACM (After the Crash of Microsoft). After many years of peace, a war has broken out. Your nation, the island of Evergreen Macros And
Time of Update: 2018-12-05
// Where’s Waldorf? (序找單詞)// PC/UVa IDs: 110302/10010, Popularity: B, Success rate: average Level: 2// Verdict: Accepted// Submission Date: 2011-05-22// UVa Run Time: 0.016s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net////
Time of Update: 2018-12-05
文章目錄 Sample InputSample Output Problem C: Arctic NetworkThe Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used
Time of Update: 2018-12-05
#include<iostream>using namespace std;bool prime(int x){// prime 函數判斷一個數是否為素數 for(int i=2;i*i<=x;i++)//只需要窮舉到√n if(x%i==0) return false; return true; }int main(){ int n,count,i; while(scanf("%d",&n)
Time of Update: 2018-12-05
// WERTYU (WERTYU 鍵盤)// PC/UVa IDs: 110301/10082, Popularity: A, Success rate: high Level: 1// Verdict: Accepted// Submission Date: 2011-05-17// UVa Run Time: 0.012s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net#include <iostream>using namespace
Time of Update: 2018-12-05
// Poker Hands (撲克牌型)// PC/UVa IDs: 110202/10315, Popularity: C, Success rate: average Level: 2// Verdict: Accepted// Submission Date: 2011-05-23// UVa Run Time: 0.008s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net////
Time of Update: 2018-12-05
// Yahtzee (Yahtzee 遊戲)// PC/UVa IDs: 110208/10149, Popularity: C, Success rate: average Level: 3// 著作權(C),邱秋,2011。metaphysis at yeah dot net// Verdict: Accepted// Submission Date: 2011-05-16// UVa Run Time: 0.088s////
Time of Update: 2018-12-05
唉,是一道水題,但是錯把b也為a,狂wa。。。 還有每次模數,否則,溢出。 下面是代碼:#include<stdio.h>#include<string.h>#define maxn 15struct node{ int m[maxn][maxn]; void init() { memset(m,0,sizeof(m)); }} A,B;int k,m;void init(){ A.init();
Time of Update: 2018-12-05
// Australian Voting (澳大利亞投票)// PC/UVa IDs: 110108/10142, Popularity: B, Success rate: low Level: 1// Verdict: Accepted// Submission Date: 2011-05-22// UVa Run Time: 0.844s//// 著作權(C)2011,邱秋。metaphysis # yeah dot net#include <iostream>#include
Time of Update: 2018-12-05
關於AC自動機,沒有多講的。別人講的在多也不如自己去看論文。這就是真理啊。 下面是: Aho-Korasick Automaton的原版論文 notonlysuccess部落格推薦的論文 AC 自動機就是要構造一個模式比對機 模式比對機有一系列的狀態(state),每個狀態用一個正整數表示 模式比對機還有狀態轉移函數和一個輸出函數 當來一個字元x時,模式比對機就處理這個字元,如果有這個字元確定的狀態,那麼就匹配下一個字元,沒有就狀態轉移。
Time of Update: 2018-12-05
Uva 11136 - Hoax or what 這道題可以用優先隊列做,這裡討論一下用最小-最大堆做。 題目的要求:需要找到最小值和最大值,並且還有刪除最小值和最大值。 這樣就需要一種包括下面幾種操作的資料結構:insert 插入一個元get_min() 得到最小元素,並將其從集合中刪除get_max()的到最大元素,並將其從集合中刪除
Time of Update: 2018-12-05
資料結構中典型的用棧解決的問題直接調用c++ STL模板庫中的棧就可以解決了#include<iostream>#include<stack>using namespace std;// 棧的五種操作stack <char> my; //定義棧my.empty() ; // 判斷棧是否非空my.size(); // 判斷棧中元素的個數my.push(a[i]); // 壓棧my.top(); // 取出棧頂元素my.pop(