livingonhope's blog

By livingonhope, history, 5 months ago, In English

Hello , can u provide some resources to learn Trees and Graphs from scratch like some playlist or course and it should on a good level ( by that I mean I get problem solving as well not just the concepts ) it would be very helpful if u can provide some ..Thannks

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By livingonhope, history, 12 months ago, In English

Hello everyone ..can u suggest some good yt tutorials or CF blogs from where i can learn Digit DP and** DP Bitmasking** .. i have tried few like Karthik Arora sir's Playlist but that didn't help .. and i m solving CSES as well to understand but i m stuck at those topics . It would be very helpfull if u could suggest some

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By livingonhope, history, 12 months ago, In English

Heres the code and problem link as well plzz help me undertand why is it failing .it will be very helpfull Problem Link — https://codeforces.me/contest/1829/problem/G Code ( C++) :

include <bits/stdc++.h>

using namespace std;

define ll long long

set ans;

int compute_row(int x) { int l = 1, r = 50000; while (l < r) { int m = (l + r) / 2; if (m * (m + 1) / 2 >= x) r = m; else l = m + 1; } return l; }

vector dp;

void solve(int n) { if (n <= 0 || dp[n]) return; dp[n] = 1;

ans.insert(n);

int row = compute_row(n);
int val1 = n - row;
int val2 = n - row + 1;

if (val1 >= 1 && compute_row(val1) < row)
    solve(val1);

if (val2 >= 1 && compute_row(val2) < row)
    solve(val2);

}

int main() { int t; cin >> t; while (t--) { int n; cin >> n; ans.clear(); dp.assign(n + 10, 0);

solve(n);

    ll sum = 0;
    for (int x : ans) sum += 1LL * x * x;

    cout << sum << endl;
}

}

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it