Блог пользователя unt311

Автор unt311, история, 3 года назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +25
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +33
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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).

Полный текст и комментарии »

  • Проголосовать: нравится
  • +50
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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...

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

Автор unt311, история, 3 года назад, По-английски

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 ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

Автор unt311, история, 4 года назад, По-английски

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) ]

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор unt311, история, 4 года назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор unt311, история, 4 года назад, По-английски

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 ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится

Автор unt311, история, 4 года назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор unt311, история, 4 года назад, По-английски

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 ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -22
  • Проголосовать: не нравится

Автор unt311, история, 4 года назад, По-английски

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)

Полный текст и комментарии »

  • Проголосовать: нравится
  • -11
  • Проголосовать: не нравится