Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

unt311's blog

By unt311, history, 3 years ago, In English

I tried solving problem magic numbers with iterative digit dp. But it runs slower than my recursive solution by more than 200ms.

iterative : link

recursive : link

I also avoided using modulo operations in my iterative code, but am surprised to see it running slower.

Any idea why this happened?

Full text and comments »

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

By unt311, history, 3 years ago, In English

The actual question is how to not get tricked by codeforces UI.

When I hover the cursor over a contest(in the performance graph), I can almost never reach the box with the link to standings as the focus shifts on to some other contest that is near that point in the graph. Is there any workaround for this ?

or does everyone play that game to run the cursor quickly towards the link before it shifts.

Full text and comments »

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

By unt311, history, 3 years ago, In English

Can we include the basic information like definition of subarray, subsequence, tree, connected graph, etc as text spoilers. This could help in making statements short and clear.

Just like at atcoder

Full text and comments »

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

By unt311, history, 3 years ago, In English

I couldn't find relevant answers to this online.

If I do int pos = iterator1 - iterator2

would this be an O(n) or a O(1) operation.

Full text and comments »

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

By unt311, history, 3 years ago, In English

why are kotlin heroes problems reserved for kotlin even after the contest.

It is fair to promote its usage by only allowing kotlin during the contest, but after the contest ends, problems are just problems(not kotlin problems duh).

Full text and comments »

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

By unt311, history, 3 years ago, In English

I've rechecked my submission several times, but do not see anything wrong. (I'm getting WA on test 3) I checked the standings but couldn't find anyone doing it my way, so I'm stuck. I've read the tutorial and understand it fully, though I wish to know what went wrong with this approach.

what I'm doing is:

I store the brightness of the star at (x, y) for times t = 0 ... c in a[time][x][y]

The sum of brightness of stars at time t(between 0...c) upto (x, y) from (1, 1) in ps[time][x][y]

now, for queries: at time t, the sky would look same as what it looked at time t % (c + 1), as its given that brightness is periodic on c.

I get the answer from sum betweeen (x1, y1) and (x2, y2) of sky at time t % (c + 1)

Thanks in advance...

Full text and comments »

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

By unt311, history, 3 years ago, In English

for positive numbers x, y (both less than 1e9)

Can the fraction of (x / y) be represented as x * inv(y) for various values of x and y (within 1e9)

I get a Wrong Answer in a div3 D problem by doing so [submission]

NOTE: I am using 1e9 + 7 for modulo operations in calculating the inverse

Full text and comments »

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

By unt311, history, 3 years ago, In English

I've been trying to do this question since many hours and am unable to visualize the authors solution. The question involves maintaining a 1d dp from a 2d dp.

I'm unable to understand what does dp[j] represent in the authors solution after ignoring (i) from dp states ?

Full text and comments »

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

By unt311, history, 3 years ago, In English

For this div3 problem (D),

I precalculate prefix frequencies of characters (editorial code does not), and I'm still getting TLE

My solve function's parameters are - 1. int c (character 0 is 'a', 25 is 'z') 2. int i (starting point of substring in consideration) 3. int j (length of the substring in consideration) [ using (1<<j) ]

Full text and comments »

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

By unt311, history, 3 years ago, In English

I applied mo's algorithm the recent cut and stick problem

My code takes 2823 ms While, to my surprise this takes 1326(its codeNcode's submission).

Both do almost the same thing, I don't see any difference other than using structs over tuples.

Full text and comments »

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

By unt311, history, 3 years ago, In English

In my opinion, using box size as (int)sqrt(n) is best for mo's algorithm.

But my two submissions differ in just that(fixing block size or taking it as (int)sqrt(n), and one gets TLE and other one gets AC.

What is the logic here ?

Full text and comments »

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

By unt311, history, 3 years ago, In English

Please share your dfs with lambda function code or improve mine.

        function<void()> dfs = [&](int a, int par, int depth) {
            vis[a] = true;
            if(depth > maxDepth){
                maxDepth = depth;
                farthestNode = a;
            }
            for(auto x: adj[a]){
                if(!vis[x])
                    dfs(x, a, 1 + dep);
            }
        };

I get the following error. error: no match for call to '(std::function<void()>) (long long int&, long long int&, long long int)'|

NOTE: changing a to &a and p to &p in parameter list does not make the error go away.

Full text and comments »

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

By unt311, history, 3 years ago, In English

I am very unhappy with getting TLE in recent contests for submissions that were of the exact same complexity as the editorial I saw afterwards :

  1. Happened in D problem of the latest Div3. My nlog(n) submission didn't pass(TLE).

  2. Again happened in C problem of Divide by zero contest. My O(n) solution didn't pass (TLE).

  3. Again happened today problem B (last div2) My optimal solution didn't pass (TLE) (Editorial isn't out yet, but I wasn't expecting TLE at all)

Do I mess up everytime or is CF behaving unfair with me ?

Full text and comments »

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

By unt311, history, 3 years ago, In English

This is a very cool problem with a short simple problem statement. I am getting TLE for a O(n * (logn)^2) solution.

Please provide a solution, or give suggestions to improve my solution (using binary search and segment tree)

Full text and comments »

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