DP Tree - do you use bottom-up or dfs + memo?

DP Tree - do you use bottom-up or dfs + memo?

I've solved this problem: https://atcoder.jp/contests/dp/tasks/dp_p , because I try to master every pattern in DP but it was very hard to code. What do you think? This is my bottom-up code ... I felt its overcomplicated but heard that I should focus on bottom-up afterall.

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;

#define for1d(i,n) for(int i = 0; i < (n); ++i)

const int MOD = 1e9 + 7;
int N = 0;

int main()
{
  cin >> N;

  if (N == 1)
  {
    cout << 2;
    return 0;
  }

  vvll adjList(N);
  vll degree(N, 0);

  ll x, y;
  for1d(i, N - 1)
  {
    cin >> x >> y;
    adjList[x - 1].push_back(y - 1);
    adjList[y - 1].push_back(x - 1);
    degree[x - 1]++;
    degree[y - 1]++;
  }

  vvll dp(N, vll(2, 1));   // dp[v][0] = white, dp[v][1] = black; identity until children fold in
  vb visited(N, false);
  queue<int> bfs;

  for1d(i, N)
  {
    if (degree[i] == 1)
    {
      bfs.push(i);
    }
  }

  int last = -1;
  while (!bfs.empty())
  {
    int v = bfs.front();
    bfs.pop();
    visited[v] = true;

    int p = -1;
    for (int u : adjList[v])
    {
      if (!visited[u])
      {
        p = u;
        break;
      }
    }

    if (p == -1)
    {
      last = v;
    }
    else
    {
      dp[p][1] = (dp[p][1] * dp[v][0]) % MOD;
      dp[p][0] = (dp[p][0] * (dp[v][0] + dp[v][1])) % MOD;
      degree[p]--;
      if (degree[p] == 1)
      {
        bfs.push(p);
      }
      else if (degree[p] == 0)
      {
        last = p;
      }
    }
  }

  cout << (dp[last][0] + dp[last][1]) % MOD;

  return 0;
}
u/Effective_Purple1054 — 10 days ago
▲ 1 r/saigon+1 crossposts

Could you recommend any LEGIT AirBnb/Hotel in Saigon with real kitchen?

Hi, It will be our first visit in Ho Chi Minh City (and even in Vietnam). Usually we book airbnb because we like to have kitchen but due to our reasearch there is a ton of scam aribnbs with fake reviews (those legit are low and usually say: photos are fake). Personally we are tired of it because its hard find something without redflags xD.

Do you have any recommendation for hotel or legit host but also without paying tons of money? (like 300-400 euro per 8 days)

Thanks in advance!

reddit.com
u/Effective_Purple1054 — 13 days ago
▲ 2 r/sennheiser+1 crossposts

Dell Pro Max 16 Premium + Sennheiser HD 560S not detected as headset (recognized as Line Out instead)

Hi everyone,

I'm running into a very strange issue with my new Dell Pro Max 16 Premium running Windows 11.

My Sennheiser HD 560S (original cable, 3.5 mm TRS, no microphone) are not working at all when connected to the laptop.

Here's what happens:

  • Windows detects them as "Line Out on SoundWire Device" instead of Headset.
  • No sound comes through the headphones.
  • Audio continues playing through the laptop speakers.
  • In Device Manager / PowerShell I can see:
    • SoundWire ACX Streaming for SDW - Line OutOK
    • SoundWire ACX Streaming for SDW - Headset EarphoneUnknown
  • The CS42L43 UAJ device is present and running correctly, so the laptop appears to detect that something was plugged into the jack.

The confusing part is:

  • Other wired headphones are detected correctly as "Headset" and work perfectly on the same laptop.
  • The Sennheiser HD 560S work perfectly on my desktop PC.
  • So neither the laptop's headphone jack nor the headphones themselves appear to be defective.

I've already tried:

  • Updating the BIOS to the latest available version (1.9.0).
  • Installing all available Dell/Windows driver updates.
  • Rebooting the system multiple times.
  • None of the above changed the behavior.

Current software:

  • Windows 11
  • BIOS: 1.9.0
  • Cirrus Jack Retasking Audio Module: 1.0.670.61082
  • Cirrus Logic audio drivers are installed (not Microsoft's generic HD Audio drivers).

One additional complication is that this is a company-managed laptop, and my IT administrator has blocked Microsoft Store for all users. Because of that, I cannot install or test the Waves MaxxAudio application, if it is required for proper jack detection.

At this point it feels like the Cirrus Logic / SoundWire driver is misclassifying the HD 560S and activating the Line Out endpoint instead of Headset Earphone.

Has anyone experienced something similar with Cirrus Logic (CS42L43 / SoundWire) or specifically with Sennheiser HD 560S?

Does anyone know whether Waves MaxxAudio is actually required on recent Dell laptops with Cirrus Logic + SoundWire, or should headset detection work correctly without it?

I'd really appreciate any ideas or confirmation that this is a driver compatibility issue rather than a hardware fault.

Thanks!

reddit.com
u/Effective_Purple1054 — 23 days ago
▲ 1 r/roblox

How did Grow a Garden 2 bypass the new audience restrictions?

I thought new Roblox games had to first gain enough Highly Engaged Players before being shown to younger audiences.

Grow a Garden 2 seemed to be available to kids almost immediately and already has massive player numbers.

Did it hit the threshold on day one, or are there exceptions for certain experiences/devs?

Trying to understand the system, not start drama.

reddit.com
u/Effective_Purple1054 — 2 months ago

Best way to organize pet assets (preview model, inventory item, world model)?

Hi,

I'm working on a system where creatures are shown only locally during a minigame. If the player wins, the creature is added to their Backpack (it can be seen by everyone), and later they can sell or place it in their ranch/farm.

What's the usual way to organize assets for something like this?

I see that I need:

  1. Models directory with rigged model.

  2. Tools directory with rigged models and handles to it. (is it good idea? I saw it on kick a lucky block)

  3. Visuals only for local client in minigame? Something lightweight. Models in minigame won't be using animations (eventually idle) but then I need to pay someone additionally for sprites to it so costs are increasing.

Hmmm I feel that I am overengineering something.

reddit.com
u/Effective_Purple1054 — 2 months ago

Question to indie developers producing a game after 9-17 job. How often do you provide updates to keep your game successful?

Sometimes I see that in some games there is an update every week ... Do you guys really have time to do that?

reddit.com
u/Effective_Purple1054 — 2 months ago
▲ 9 r/RobloxDevelopers+1 crossposts

Are there common patterns for systems like tycoons, minigames, progression, economy, etc.?

I've been working professionally on large C++ projects for about 6 years, but not in the game development industry.

Recently I've started learning Roblox development. I've already learned Lua, understand client/server architecture, ModuleScripts, Services, controllers, modularity, general design patterns (like singleton, factory, builder), etc.

What I'm looking for now is something closer to architecture and frameworks

For example, many developers have already built:

  • tycoons,
  • inventory systems,
  • currencies/economies,
  • minigames,
  • progression systems,
  • session-based gameplay,
  • data persistence,
  • client/server gameplay loops.

Are there any widely accepted frameworks, architecture guides, books, open-source projects, or collections of best practices that explain how experienced Roblox developers typically structure and solve these kinds of problems?

I'd rather learn from proven solutions than reinvent the wheel for every feature.

Thanks in advance!

reddit.com
u/Effective_Purple1054 — 3 months ago
▲ 3 r/roblox

Will you let your kid play your game?

I have those thought after next peak of players in slime rng.

I feel that some RNG is ok. Even steal a brainroot for me is ok. All that brainroot stuff looks boring but still ... if it doesn't have those slots vibes then its acceptable (unfortunatelly we have to accept some bias).

But obvious slots roll animatinos like in "slime rng" or "kick a lucky block"? Wtf ... Guys I think its too much. I am feeling that it should be restricted for min 16 YOE.

I don't know what to do. I am professional SWE from other industry who wanted to make a roblox game for fun and money but I feel its no other option but design it strictly for addiction and money. Either I make a soft casino game or I will be having 100 players max and waste time.

What are your feeling about it? Maybe I am overreacting and it’s none of my business how parents raise their kids?

reddit.com
u/Effective_Purple1054 — 3 months ago

Who is playing a game like this?

It has 16k active players but this game is a copy of the copy of the copy of some brainroot game. Do you think that author bought a bot farm or brainroot is still very popular business model?

u/Effective_Purple1054 — 3 months ago