angry_pikachu's blog

By angry_pikachu, history, 15 months ago, In English

Source — Link

Given a string with lowercase letters and “?” where each “?” can be replaced by any lowercase character, find the total number of strings such that the first and last characters are the same and no adjacent characters are the same.

I am still new to DP, help would be appreciated

Full text and comments »

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

By angry_pikachu, history, 18 months ago, In English

I am getting error

prog.cpp: In lambda function:

prog.cpp:118:28: error: use of ‘dfs’ before deduction of ‘auto’

118 | for(ll it: nde[i]) dfs(it,fren[i]);

In this code , ll means long long, nde[i] is a vector of int

auto dfs = [&](int i,int x)->void{
        for(ll it: nde[i]) dfs(it,fren[i]);

Writing a blog in codeforces for first time

C++ 17 online compiler

Worked using

    function<void(int, int)> dfs = [&](int i, int x) -> void {
        fren[i] += x;
        for (ll it : nde[i])
            dfs(it, fren[i]);

Also by changing vector<int> nde[n] to vector<vector<int>> nde(n) and by using the function

    auto dfs = [&](int i,int x, auto &&dfs)->void{
        for(ll it: nde[i]) dfs(it,fren[i], dfs);

Full text and comments »

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