From a390ac813b5901233ff9e1f11de9d27ed82aa3a1 Mon Sep 17 00:00:00 2001 From: 13307130498 <13307130498@fudan.edu.cn> Date: Sat, 27 Dec 2014 12:22:43 +0800 Subject: [PATCH] Assignment10 completed --- 13307130498/assignment10/Decode the tree.cpp | 74 +++++++++++++++++++ .../assignment10/Distinct Sub-matrix.cpp | 36 +++++++++ .../assignment10/Language Cardinality.cpp | 49 ++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 13307130498/assignment10/Decode the tree.cpp create mode 100644 13307130498/assignment10/Distinct Sub-matrix.cpp create mode 100644 13307130498/assignment10/Language Cardinality.cpp diff --git a/13307130498/assignment10/Decode the tree.cpp b/13307130498/assignment10/Decode the tree.cpp new file mode 100644 index 0000000..78d4738 --- /dev/null +++ b/13307130498/assignment10/Decode the tree.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +using namespace std; + +struct node{ + int fa,de; + int n; + int a[400]; +}nodes[400]; +int m,k,a[400]; +int ord[400],sum; +bool f[400]; +string s,num; + +void dfs(int x){ + printf("(%d",x); + for(int i=0;i='0'&&s[i]<='9'&&f[i]){ + num=""; + int j=i; + while(s[j]>='0'&&s[j]<='9'){ + f[j]=0; + num+=s[j++]; + } + k=0; + for(int j=0;j<=num.size()-1;j++){ + k = k*10 + (num[j]-'0'); + } + a[k]++; + ord[sum++]=k; + if(m +#include +#include +#include + +using namespace std; + +int main(void){ + int t, n ,m; + cin>>t; + for(int cnt = 1;cnt <= t; cnt++){ + set mat; + cin>>n>>m; + string *l = new string[n]; + long long li[m], c; + int i,j,k,p,q; + for(i=0;i>l[i]; + for(i=0;i +#include +#include +#include +#include +using namespace std; +struct A{ + string ori,rep; +}ru[101]; +int size,i,j; +string s,x; +set bef; +void cal(string str){ + for(int m=0;m1000)throw "XYWBD"; + cal(newstr); + } + jj=str.find(ru[m].ori,jj)+1; + } + } +} +int main(void){ + cin>>s; + s=s.substr(1,s.size()-2); + i=j=0; + while(cin>>x){ + j=x.find("->"); + ru[i].ori=x.substr(1,j-2); + ru[i].rep=x.substr(j+3,x.size()-j-4); + i++; + } + size=i; + bef.insert(s); + try{ + cal(s); + } + catch(const char *mm){ + cout<<"Too many."<