Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

aryanc403's blog

By aryanc403, 2 years ago, In English

1997A - Strong Password

Hint
Video editorial

1997B - Make Three Regions

Idea
Video editorial

1997C - Even Positions

Hint
Discussion

1997D - Maximize the Root

Video editorial

1997E - Level Up

Hint 1
Hint 2
Hint 3
Hint 4
Video editorial
Daily Chat QnA
  • Vote: I like it
  • +10
  • Vote: I do not like it

»
18 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My answer for the part D is giving wrong answer on 19th test case

bool check(map<ll, vector<ll>> &mp, vector<ll> &a, ll k){

    queue<pair<ll, ll>> qu;
    for(ll i: mp[1]) qu.push({i, k - a[1]});

    while(!qu.empty()){
        auto curp = qu.front(); qu.pop();
        ll cur = curp.first;
        ll sub = curp.second;

        ll moda = a[cur] - sub;

        if(mp[cur].size() == 0 && moda < 0) return false;

        if(moda < 0) sub -= moda;

        for(ll i: mp[cur]) qu.push({i, sub});
    }

    return true;
}

can somebody help?