Esempio n. 1
0
/* Lukas P.P.P. van Ginneken algorithm for optimal buffer insertion in
   RC-tree.
*/
static Options
bottom_up(Tree k, Bool no_buf)
{
 Options Z, Z1, Z2;

  if (T_LEAF(k))
    Z = options_sink(k);
  else {
    Z1 = bottom_up(T_SUB1(k), no_buf);
    Z2 = bottom_up(T_SUB2(k), no_buf);
    
    /****************************/
    /** IMPLMENT THIS FUNCTION **/

    Z  = options_combine(Z1, Z2);

    /***************************/
  }
  Z = options_add_wire(Z, T_WIRE(k));
  if (!no_buf)
    Z = options_add_buffer(Z);
  if (debug)
    node_options_show(stdout, Z, k);
  return Z;
}
Esempio n. 2
0
int main() {
	int p[] = {1, 5, 8, 9, 10, 17, 17, 20};
	int length = sizeof(p) / sizeof(p[0]);
	printf("Max price of the cut (using bottom up) is: %d\n", bottom_up(p, length));
	printf("Max price of the cut (using top down) is: %d\n", top_down(p, length));
	return 0;
}
Esempio n. 3
0
int
main(int argc, char *argv[])
{
  Tree t;

  if (argc > 1 && argv[1])
    if (!freopen(argv[1], "r", stdin)) {
      fprintf(stderr, "Cannot open file `%s' for reading.\n", argv[1]);
      return EXIT_FAILURE;
    }

  t = parse();

  pair_show(stdout, OPAIR(bottom_up(t, 1)));
  fprintf(stdout, "\n");
  pair_show(stdout, OPAIR(options_last(bottom_up(t, 0))));
  fprintf(stdout, "\n");

  return EXIT_SUCCESS;
}
Esempio n. 4
0
int main(void)
{
	scanf("%d", &N);

	bottom_up(N);

	result = DT[N][0] + DT[N][1];

	printf("%lld\n", result);

	return 0;
}
Esempio n. 5
0
int main(void) {

	//입력
	scanf("%d", &N);

	bottom_up(N);

	answer = memo[N];

	printf("%d\n", answer);

	return 0;
}
Esempio n. 6
0
int main(void)
{
	scanf("%d", &N); //input

	bottom_up(N);
	for (int i = 0; i <= 9; i++) {
		answer += DT[N][i];
		answer %= 1000000000;
	}

	printf("%d\n", answer);

	return 0;
}