注意题目给的最后一句话,如果部门任何employee都做不同类型的工作,则这个部门是一个diverse,题目是计算department的diverse数
读起来感觉有点别扭,英语没学好的原因
int countGood(vector <int> superior, vector <int> workType) { int res = 0; for(int i = 0 ; i < superior.size(); ++ i){ set<int> department; department.insert(workType[i]); int num = 1; for(int j = i+1; j < superior.size(); ++ j ){ if(superior[j] == i){ department.insert(workType[j]); num++; } } if(num == department.size()) res++; } return res; }
topcoder SRM 619 DIV2 GoodCompanyDivTwo,布布扣,bubuko.com
时间: 2024-10-05 06:33:09