某公司需要在项目中引入某开源工程,需要评估该开源工程中某模块的编译时间,
当前已知该项目中每个模块的编译时间以及依赖模块列表,在拥有无限数量的并行
任务情况下,求某个指定模块的最短编译时间。
若模块间存在循环依赖或依赖模块不存在,则无法完成编译,返回-1;
输入描述:
第一行输入为目标模块名;
以后每一行输入定义一个模块,包含模块的名字,编译时间,依赖模块列表,用逗号隔开,若依赖模块列表不存在,则表示可以独立编译,例如:
module2,10,module1
module1,10
模块名只包含字母和数字且至少包含一个字符,模块数量不超过50000个。
输出描述:
输出最短编译时间,若无法完成编译则输出-1;
例如:输入
module3
module1,10
module2,5
module3,10,module1,module2
输出:
20
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct module_t
{
char name[255];
int time;
int isCompiled;
struct module_t *next;
struct module_t *depends;
}module_t;
int parseInput( module_t **mds, char * buf , char