Page 1 of 1

A city has n intersections and m bidirectional roads connecting pairs of intersections. Each road has a certain traffic

Posted: Wed Apr 27, 2022 3:34 pm
by answerhappygod
A city has n intersections and m bidirectional roads connecting
pairs of intersections. Each road has a certain traffic flow
capacity, measured in cars per minute. There is a path from every
intersection to every other intersection along some sequence of
roads. The road maintenance department is over budget and needs to
close as many roads as possible without disconnecting any
intersections. They want to do it in such a way that the minimum
capacity among all of the remaining roads is as large as possible.
Your program should read the input from the file, and output the
answer to another file. The first argument is the input file name,
while the second argument is the output file name.
Input file: First line contains two integers n m (0 < n ≤
100, 0 < m ≤ 10000). The next m lines will describe the m roads,
each one using 2 names and 1 integer, u, v and c (0 < length(u),
length(v) ≤ 80, 0 < c ≤ 1000). u and v are the endpoints of the
road and c is its capacity. You can assume the name of
intersections are strings containing letters [A-Za-z] only. Output
file: Output an integer, the capacity of the minimum-capacity
remaining road.
A City Has N Intersections And M Bidirectional Roads Connecting Pairs Of Intersections Each Road Has A Certain Traffic 1
A City Has N Intersections And M Bidirectional Roads Connecting Pairs Of Intersections Each Road Has A Certain Traffic 1 (12.21 KiB) Viewed 75 times
int main(int argc, char *argv[]){

FILE *fin, *fout;
int i, j, w, n, e;
int ans = 0;
char name[100][82];
int name_count = 0;
char name1[82], name2[82];

fin = fopen(argv[1], "r");
fout = fopen(argv[2], "w");

fscanf(fin, "%d%d", &n, &e);

/* Your code here */



memset(name, 0, sizeof(name));
memset(name1, 0, sizeof(name1));
memset(name2, 0, sizeof(name2));
for (i = 0; i < e; i++) {
fscanf(fin, "%s%s%d", name1, name2, &w);
/* Your code here */


memset(name1, 0, sizeof(name1));
memset(name2, 0, sizeof(name2));
}

/* Your code here */



/* Output format */
fprintf(fout, "%d\n", ans);

/* Your code here */

fclose(fin);
fclose(fout);

return 0;
}
Sample Input: 4 5 CUHK PSK 1 FoTan PSK 2 PSK Shatin 3 Shatin FoTan 4 CUHK Shatin 5 Sample Output: 3 3