文章
99
粉丝
120
获赞
8
访问
97.5k
#include <iostream>
#include <map>
using namespace std;
map<string, int> stringToInt;
map<int, string> intToString;
map<string, int> ans;
int idNumber = 1, k;
int stoifunc(string s) {
if (stringToInt[s] == 0) {
stringToInt[s] = idNumber;
intToString[idNumber] = s;
return idNumber++;
}
else {
return stringToInt[s];
}
}
int G[2010][2010], weight[2010];
bool vis[2010];
void dfs(int u, int& head, int& numMember, int& totalweight) {
vis[u] = true;
numMember++;
if (weight[u] > weight[head])
head = u;
for (int v = 1; v < idNumber; v++) {
if (G[u][v] > 0) {
totalweight += G[u][v];
G[u][v] = G[v][u] = 0;
if (vis[v] == false)
dfs(v, head, numMember, totalweight);
}
}
}
void dfsTrave() {
for (int i = 1; i < idNumber; i++) {
if (vis[i] == false) {
...
登录后发布评论
暂无评论,来抢沙发