Комментарии
На LoneFox → Facebook Hacker Cup 2021: Round 2, 5 лет назад
0

pribic,

I haven't yet looked into problem B. But, if you know in advance the parameters for which the recursive function will be called, then you can call it pro-actively.

  static int[] desti_done = new int[10000];

  private static int desti(int f) {
    if (desti_done[f] != 0)
      return desti_done[f];

    if (f == 0 || f == 1)
      desti_done[f] = 1;
    else
      desti_done[f] = desti(f-1) + desti(f-2);

    return desti_done[f];
  }

desti(10000) may NOT work. But you can call 100 at a time as following:

  for (int i = 0; i < 10000; i += 100)
    desti(i);

  int ans = desti(10000);
На darkkcyan → Codeforces Round #763 (Div. 2) Editorial, 5 лет назад
+8

The O(1) solution explanation for the first one — Robot cleaner is awesome! Also in the pascal solution, I appreciate the usage of the function solve_single.

На Bakry → Codeforces Round #746 Editorial, 5 лет назад
0

I'm trying to solve problem D in the following way:

After getting max value by querying N nodes, query for N/2 nodes.

If the ans is less than max, then remove all the edges which are made up these nodes at both the ends.

If the ans is max, then keep all the edges which are made up these nodes at both the ends, remove other edges.

With the help of remaining edges, again figure out N/4 nodes, and query it. Keep going this way, and in the end, only one edge will remain.

Any issue with this approach?

The solution is failing : https://codeforces.me/contest/1592/submission/130812435 . Is there a logical bug or an implementation bug?