51stDimension's blog

By 51stDimension, history, 11 months ago, In English

Hey everyone,

So currently I am designing something related to esports and I want to make CP mainstream in as many countries as possible by conducting contests in it as part of esports. So what my website would do is conduct custom gym contests here in codeforces in lockout format, my website would poll the spectator link and would give out alarms and all whenever a problem is solved and the winner would be given a badge or some sort of incentive like that. So basically just an attempt to make CP more mainstream and not just to crack companies. All I wanted to ask is: Is this allowed? or I would be breaking some kind of law doing this?

Thanks

Full text and comments »

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

By 51stDimension, history, 3 years ago, In English

Problem Link

According to the Editoral

The answer is supposed to be

Let K be = Number of components such the number of edges == number of vertices then the answer is pow(2,k)

I used the same method but I calculated the number of cycles in each connected component. Le var be a variable. And if the cyclecount in a connected component is == 1 then I do var++ and later on the ans = pow(2,var)

I am getting 6 WA.

My Code

There is a possibility that my cycleCount function is wrong. If thats the case please do let me know!

Thank you!

Full text and comments »

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

By 51stDimension, history, 3 years ago, In English

Quesion Link Leetcode: Leetode Question Link Codeforces Link

This problem has a binary search solution which goes like this:

class Solution {
    public boolean enough(int x, int m, int n, int k) {
        int count = 0;
        for (int i = 1; i <= m; i++) {
            count += Math.min(x / i, n);
        }
        return count >= k;
    }

    public int findKthNumber(int m, int n, int k) {
        int lo = 1, hi = m * n;
        while (lo < hi) {
            int mi = lo + (hi - lo) / 2;
            if (!enough(mi, m, n, k)) lo = mi + 1;
            else hi = mi;
        }
        return lo;
    }
}

The only doubt that I have is how come we are sure that this algorithm will give a answer which lies in multiplication table because not all numbers from [1:n*m] are present in the table. For example this is a table for n=5 and m=7 and has missing numbers like 11,22,23 etc. 1 2 3 4 5 6 7 2 4 6 8 10 12 14 3 6 9 12 15 18 21 4 8 12 16 20 24 28 5 10 15 20 25 30 35

Full text and comments »

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