ivanz's blog

By ivanz, 3 years ago, In English

It is very sad to see interlude at the bottom of the user rating by contribution. I liked Round #745, even considering that I solved only one problem in the first division. The tasks seemed interesting to me, they do not have complicated statements and there is something to think about.

It seems to me that many people did not like that the C problem was solved by a complete brute force with clipping.

My solution works like this: we iterate over the upper left cell of the rectangle containing the portal, then its height, and we will iterate over the width until the number of actions to create a given portal exceeds 16 (it is from so many cells the portal of the minimum allowable size consists). It is not immediately clear why, with such a clipping, the solution will work quickly, most likely this task could seem difficult to contestants. (You can try to read my comment. Maybe it will help you to understand why it works fast).

Although, it seems to me, this is not such a rare technique when in a not very complex problem (that is, in a problem where complex algorithms are hardly used), in which it is not immediately clear what to do, the optimal solution is a slightly optimized brute force.

The tasks following C were also probably difficult for most of the participants in the second division.

In any case, the tasks were of high quality and not boring. There were also no significant problems with statements or tests during the round. Such an amount of hatred towards authors seems unreasonable to me. Therefore, before you put downvote, think carefully about your decision.

Many thanks to the authors for good tasks, I am looking forward to participate in the next contest prepared by you.

Full text and comments »

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

By ivanz, history, 3 years ago, translation, In English

Hello! I ran into a following problem. I downloaded Code::Blocks 20.03 MinGW version here. If I select C++14 and try to compile program using bits/stdc++ everything is OK.

But when I select C++17 a mistake occurs:

If I don't use bits/stdc++.h but include the libraries separately everything works with C++14 and with C++17. So the problem is exactly in this library. What I need to do to make bits/stdc++ working with C++17?

UPD: this helps:
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>

Full text and comments »

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

By ivanz, history, 3 years ago, In English

I have two structures declared this way:

struct dot {                                                                                            
    int x, y;                                                                                            
};                                                                                            
                                                                                            
                                                                                            
struct pig : dot {                                                                                            
    int z;                                                                                            
}; 

I can declare dot variable like this:

dot a = {1, 100};

But how can I declare pig variable? The only way I found is this:

pig b;                                                                                            
b.x = 1;                                                                                            
b.y = 100;                                                                                            
b.z = 2134;    

Is there any way to do it easier, like with dot variables?
I tried this:

pig b = {1, 100, 2133}

but it doesn't work.
Please, help!

Here's what I was looking for:

struct dot {
    int x, y;
};


struct pig : dot {
    int z;

    pig(int x_, int y_, int z_) : dot{x_, y_}, z{z_} {}
};


pig b{1, 2, 3};

Full text and comments »

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

By ivanz, history, 4 years ago, translation, In English

Hello! Could you please explain to me why my submission 94709653 gets WA4 in the problem 1422F - Boring Queries? In my solution, I just use a segment tree to calculate lcm on the segment of the array. To calculate lcm of numbers a and b I use following fact: lcm(a, b) = a * b / gcd(a, b). Also, I take into account that we calculate lcm by modulo MOD. So lcm(a, b) = (((a * b) % MOD) * solve(gcd(a, b), MOD)) % MOD, where solve(x, m) returns such y that x * y ≡ 1 (mod m). Why it gets WA4? I think the idea is correct and I used verified patterns of segtree and functions loke gcd, lcm and solve (finding an inverse element in the residue ring modulo).

Please help!!!

P.S. sorry for my poor English, I tried to use Grammarly and translator

Full text and comments »

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