Time of Update: 2018-12-04
#include<stdio.h>#include<iostream>#include<algorithm>#include<cstring>using namespace std;struct node{int degree;int position;};bool cmp(node a,node b){if(a.degree>b.degree)return true;elsereturn false; }node d[11];int m[1
Time of Update: 2018-12-04
#include<stdio.h>#include<string.h>#define MAX 109#define MA 9999999bool vis[MAX];int w[MAX][MAX];int yes[MAX][MAX];int min,i,j,t,k,n,f,begin,end,g;__int64 s;void prim(){for(i=0;i<n-1;i++){f=0;min =
Time of Update: 2018-12-04
/*之前一直求的是正序數繞過過來錯了好幾遍因為像44312這種資料*/#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int k,m,n;int c[1000010];struct node{int x,y;};node p[1000010];bool cmp(node a,node b){if(a.x==b.x)return
Time of Update: 2018-12-04
/*初識最小環渣*/#include<cstdio>#define inf 999999#define min(a,b) (a)>(b)?(b):(a)int main(){int map[150][150],g[150][150];int n,m,i,j,k,ans,a,b,c;while(scanf("%d%d",&n,&m)!=EOF){ans=inf;for(i=1;i<=n;i++)for(j=1;j<=n;j++)g[i][j]=inf;
Time of Update: 2018-12-04
/*對於菜鳥,第一次接觸這種大型演算法,應該抽出一大段時間研究,研究這個演算法我認為要有DIJ和Floyd的鋪墊。搜集各路資料,大概有以下幾個要點。1.SPFA(Shortest Path Faster
Time of Update: 2018-12-04
#include<stdio.h>#include<string.h>int main(){char a[1001];char b[1001];int T;int i,n,m,j,s;int count=0;scanf("%d",&T);while(T--){int c[1100]={0};int d[1100]={0};int
Time of Update: 2018-12-04
n不妨用Begin[i]和End[i]表示事件i的開始時刻和結束時刻。則原題的要求就是找一個最長的序列a1<a2<…<an,滿足:Begin[a1]<End[a1]<=…<= Begin[an]<End[an]可以證明,如果在可能的事件a1<a2<…<an中選取在時間上不重疊的最長序列,那麼一定存在一個包含a1(結束最早)的最長序列。(證明:略)#include<stdio.h>int main(){ int
Time of Update: 2018-12-04
深搜#include<cstdio>#include<iostream>#include<cstring>using namespace std;int num[40];int s;int vis[40];int flag;int n;bool dfs(int x,int k,int sum)//木棍序號 已完成變數 當前木棍長度 { int i; if(k==3) return 1; for(i=x;i<n;i++)
Time of Update: 2018-12-04
#include<iostream>#include<cstdio>#include<cstring>#define max_n 2using namespace std;struct M {int s[max_n][max_n];};int mod;M mul(M a,M b){int i,j,k;M
Time of Update: 2018-12-04
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>using namespace std;#define N 3010struct Tire{int num;Tire *next[26];};Tire *root;void init() //初始化{root = new Tire;for(int i = 0; i &
Time of Update: 2018-12-04
string add(string s1,string s2) { int j,l,la,lb; string max,min; max=s1;min=s2; if(s1.length()<s2.length()) {max=s2;min=s1;} la=max.size();lb=min.size(); l=la-1; for(j=lb-1;j>=0;j--,l--) max[l] += min[j]-'0';
Time of Update: 2018-12-04
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>using namespace std;//#define max_n 8001struct Tire{int num;Tire *next[10];};Tire *root;void init() //初始化{root = new Tire;for(int i=0;
Time of Update: 2018-12-04
#include<stdio.h>#include<string.h>int c1[999999];int c2[999999];int val[999999];int num[999999];int main(){int i,j,t,s,n,k;while(scanf("%d",&n)!=EOF && n>=0
Time of Update: 2018-12-04
#include<cstdio>#define Max(a,b) (a)>(b)?(a):(b)int father[10000001],boy[10000001];int maxboy;int find(int x){int r=x,tmp;while(father[x]!=x)x=father[x];while(r!=x) //路徑壓縮 { tmp=father[r]; father[r]=x; r=tmp;
Time of Update: 2018-12-04
#include<stdio.h>#include<string.h>int c1[99999999];int c2[99999999];int num[9999];int main(){int
Time of Update: 2018-12-04
/*這個題目沒什麼好說的但因為RE了將近2個小時不紀念對不起自己記住,秒殺才是王道拖得越久越不利*/#include<stdio.h>#include<string.h>#define max_n 160#define inf 1234567int vis[max_n];long dist[max_n];int map[max_n][max_n];char name[max_n][40];int n,m;void dij(int v){ int i,j,max,f;
Time of Update: 2018-12-04
Numbers in English are written down in the following way (only numbers less than 109 are considered). Number abc,def,ghi is written as "[abc] million [def]thousand [ghi]". Here "[xyz] " means the written down number xyz .In the written down number
Time of Update: 2018-12-04
/*痛點在構造矩陣構造好矩陣就可以在原有的模板求矩陣的N次方在乘上初始值我求矩陣快速冪用的是遞迴*/#include<iostream>#include<cstdio>#include<cstring>#define max_n 10#define n 10using namespace std;struct M {int s[max_n][max_n];};int mod;M mul(M a,M b){int i,j,k;M
Time of Update: 2018-12-04
講座裡講了好多最短路的演算法,沒來得及思考和應用因為目前碰到的水題,dij就完全可以解決了,目前的目標是昨天聽到的dij的二元堆積最佳化,研究成功會第一時間放到這裡。還有spfa可以解決負權的問題,由於學長是曾經研究過劉汝佳的演算法入門經典的,他十分注重一個模型,DAG。第一道hdu1548A strange lift#include<iostream>#include<cstdio>#include<cstring>#define max_n
Time of Update: 2018-12-04
#include<stdio.h>#include<string.h>int c1[9999];int c2[9999];int main(){int i,j,k,m,n;int min[1000];int