Comments

IMHO Problem B to me was like you either know it or you don't. Like, I can't get a piece of paper and start working on it and finally get an answer, but 7000+ people solving it really got me questioning my existence.

That makes sense. Thank you very much <3.

thanks

+1

as long as it's fun for me I'm ok with it :"O

+1

thanks ^^

0

thank you so much <3

0

thank you for the suggestion, i will read it.

0

Thanks :)

0

thanks :D, keep practicing and you will reach it

0

thank you

0

thank you, i practice both skills

0

Thank you, I'll definitely keep practicing

+6

thanks, i hope so too :D

0

thanks, i'll keep grinding

0

thank you

0

thank you, I appreciate your words.

0

thank you bro, you definitely will

0

thank you, you too!

+4

Thank you, i will definitely keep going!

+1

Thank you

+1

Thanks :D

0

so i see that in problem B, if we replace every A with a ( and every B with a ), it becomes a "valid bracket sequence problem", why the solution works for both, can anyone elaborate ?, thanks in advance.

+26

the submission you mentioned looks like mine (i submitted it after the contest), and mine only passes if I use the "Ofast" optimization option.

1) don't know why the submission you mentioned is faster than mine.

2) don't know why both submissions pass.

this is my code: https://mirror.codeforces.com/contest/1661/submission/153254977

probably mine is hackable.

Can you help me with why this TLEs for problem B, I'd appreciate your help, thanks in advance.

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    auto&& solve = [=](int64_t X) -> int64_t {
        std::queue<pair<int, int>> q; // pair of (number, how many operations done to reach it).
        q.push({X, 0});

        std::vector<bool> done(32768 + 1, false);

        while (!q.empty()) {
            std::pair<int, int> u = q.front();
            q.pop();
            done[u.first] = true;

            if (u.first == 0) // if the number (u.first) is congruent to 0 (mod 32768).
                return u.second; // return the number of operations done to reach it.

            for (auto nxt : {(u.first + 1) % 32768, (u.first * 2) % 32768})
                if (!done[nxt])
                    q.push({nxt, u.second + 1});
        }

        return -1; // shouldn't reach here.
    };

    while (N--) {
        int X;
        cin >> X;
        cout << solve(X) << ' ';
    }
}

[edit]: understood the idea

Thank you so much, this helps me a lot.

Thanks for the advice, definitely will start considering it while practicing.

you need to know something because i knew people would get this post wrong, i am NOT against the hardwork strategy, infact i ENJOY the process and would love to keep doing it until i am a better version of myself, but the idea is for example: person "A" reached expert in 2 yrs & person "B" reached expert in 3-4 yrs so, was person "A" Smarter in the way he approaches CP ?, we all are here to learn, you learn CP because it fits your rating, i learn how to learn CP because it fits my rating.

+12

no brain me solving question A by shuffling the array multiple times codeforces: we wont let u cry this time, Accepted

Me After Seeing The Delay:-

is it delayed ?

I have a talent at not being able to solve questions

i learned a lot from this round, good job!