Go to diff to previous submission
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int conn[2000][2000]; int pipes[2000]; int nodes; int count(int node, int from) { int i, inputc= 1000000000, childc = 0; //printf("count node %d from %d\n", node, from); if (pipes[node]==1 && from != -1) { //printf("leaf %d\n", node); return conn[node][from]; } for (i=1; i<nodes+1; i++) { if (i==from) { inputc = conn[node][i]; } else { //childc += conn[node][i]; if (conn[node][i] > 0) childc += count(i, node); } } //printf("node %d from %d input %d child %d\n", node, from, inputc, childc); if (childc == 0) return inputc; return childc > inputc ? inputc : childc; } int main(int argc, char **argv) { int rv, root, i, n1, n2, w; while (1) { if (rv != 2) break; for (i=0; i<nodes-1; i++) { conn[n1][n2] = w; conn[n2][n1] = w; pipes[n1]++; pipes[n2]++; } } return 0; }