Hoj 3133 White-box testing
来源:互联网 发布:松下plc编程实例 编辑:程序博客网 时间:2024/05/21 15:52
题目链接:http://acm.hit.edu.cn/hoj/problem/view?id=3133
简单的搜索题。
输出白盒测试的基本路径。注意题目中关于基本路径的定义。。。
考虑到有可能(不知有没有可能)标号和数量不符的情况,离散化一下。
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <stack>#include <queue>#include <map>#include <algorithm>#include <iostream>using namespace std;#define Maxn 30#define Maxm 2005struct Point{ int vis; int lchild,rchild; int child; }point[Maxn];int vis[Maxn];int ma[Maxn][Maxn];vector <int> v[Maxm];int vnum = 0;map <int,int> just;map <int,int> to;bool cmp(vector<int> a,vector<int> b){ if(a.size() == b.size()) { for(int i=0;i<a.size();i++) { if(a[i]!=b[i]) return a[i]<b[i]; } } else return a.size() < b.size();}void print(vector<int> has){ int flag = 1; for(int i = has.size()-1;i>0;i--) { flag = flag & ma[has[i]][has[i-1]]; ma[has[i]][has[i-1]] = 1; } if(flag) return; for(int i=0;i<has.size();i++) { v[vnum].push_back(to[has[i]]); } vnum++;}void dfs(int s,vector<int> has){ if(point[s].vis == 0) { point[s].vis = 1; if(point[s].rchild!=-1 && point[s].lchild!=-1) { vector<int> t1 = has; t1.push_back(point[s].rchild); dfs(point[s].rchild,t1); vector<int> t2 = has; t2.push_back(point[s].lchild); dfs(point[s].lchild,t2); } else if(point[s].child!=-1) { vector<int> t3 = has; t3.push_back(point[s].child); dfs(point[s].child,t3); } else print(has); point[s].vis = 0; } else print(has);}int main(){ #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int s; char str[20]; int a,b; char d; while(scanf(" %d",&s)!=EOF) { for(int i=0;i<Maxn;i++) { point[i].vis = 0; point[i].lchild = point[i].rchild = point[i].child = -1; } memset(ma,0,sizeof(ma)); for(int i=0;i<Maxm;i++) { v[i].clear(); } vnum = 0; just.clear(); to.clear(); int hh = 0; if(just.find(s) == just.end()) just[s] = ++hh; to[just[s]] = s; s = just[s]; while(scanf(" %s",str)!=EOF && str[0]!='E') { sscanf(str,"%d->%d,%c",&a,&b,&d); if(just.find(a) == just.end()) just[a] = ++hh; if(just.find(b) == just.end()) just[b] = ++hh; to[just[a]] = a; a = just[a]; to[just[b]] = b; b = just[b]; if(d == 'T') point[a].lchild = b; else if(d == 'F') point[a].rchild = b; else point[a].child = b; } vector <int> has; has.push_back(s); dfs(s,has); sort(v,v+vnum,cmp); printf("CC=%d\n",vnum); for(int i=0;i<vnum;i++) { for(int j=0;j<v[i].size();j++) { if(j == v[i].size()-1) printf("%d\n",v[i][j]); else printf("%d,",v[i][j]); } } } return 0;}
- Hoj 3133 White-box testing
- White box testing
- Robotium - 3: White Box Testing
- Blach-Box and White-Box Testing
- 实验二 白盒测试 White box Testing
- What is black box/white box testing -- 给大家一些英文原解
- What is the 4th Generation White-box-testing Methodology(4GWM)
- HOJ 2686 Magic-Box
- HOJ 2686 Magic-Box
- HOJ 1599-------Box of Bricks
- HOJ 1599 Box of Bricks
- Robotium - 2: Black Box Testing
- 打造一个"白盒"Linux:White Box Enterprise Linux
- TDD的主要目的是设计而不是White Box Test
- VcSmith is you best choice of white-box test tool
- White
- HOJ
- testing
- 数据库 mysql 操作
- Poj 1251 Jungle Roads -- 最小生成树
- 【PAT】1051. Pop Sequence (25)
- 香梨股份 600506 2013-08-27
- 查找二叉树中的最大距离
- Hoj 3133 White-box testing
- 【python】python 转换为json时候 汉字编码问题
- 软件编码规范
- HMM 做训练的 Sigma not positive definite (非正定的)原因及处理办法
- Java中的main线程是不是最后一个退出的线程
- n支队伍比赛,分别编号为0,1,2。。。。n-1,已知它们之间的实力对比关系, 存储在一个二维数组w[n][n]中,w[i][j] 的值代表编号为i,j 的队伍中更强的一支。
- 求1+2+3+...+n
- hashSet根据compareTo()方法的写法不同,hashSet是可以加入重复元素的(即使这2个元素的hashCode相同)。
- DOM编程之一