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

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

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.

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

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

Автор ivanz, история, 3 года назад, По-русски

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>

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

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

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

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};

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

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

Автор ivanz, история, 4 года назад, По-русски

Hello! Could you please explain to me why my 94709653 gets WA4 in 1422F - Скучные запросы? 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!!!

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

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

Автор ivanz, история, 4 года назад, По-русски

Скиньте, пожалуйста, ссылку на задачу на корневую оптимизацию в любой тест.системе "Количество циклов длины 3 в графе".

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

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

Автор ivanz, история, 4 года назад, По-русски

Скиньте, пожалуйста, ссылку на задачу "Количество различных чисел на подотрезке массива", или на задачу, сводящуюся к этой в любой тестирующей системе. Подойдет как вариант с модификацией элементов, так и без.

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

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