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

Автор vovuh, история, 5 лет назад, перевод, По-русски

1157A - Reachable Numbers

Идея: BledDest

Разбор
Решение

1157B - Long Number

Идея: BledDest

Разбор
Решение

1157C1 - Increasing Subsequence (easy version)

Идея: MikeMirzayanov

Разбор
Решение

1157C2 - Increasing Subsequence (hard version)

Идея: MikeMirzayanov

Разбор
Решение

1157D - N Problems During K Days

Идея: MikeMirzayanov

Разбор
Решение

1157E - Minimum Array

Идея: vovuh

Разбор
Решение

1157F - Maximum Balanced Circle

Идея: MikeMirzayanov

Разбор
Решение

1157G - Inverse of Rows and Columns

Идея: vovuh

Это комментарий по поводу квадратичного решения. Спасибо за упоминание этого факта, STommydx!

Разбор
Решение
Разбор задач Codeforces Round 555 (Div. 3)
  • Проголосовать: нравится
  • +34
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

The editorial for Problem G looks like a little the editorial of Problem F

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

it was a greedy contest :D Good round by the way

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

My solution problem D after contest(sad): 1)Find minimum first element with binary search 2) let's get maximum suffix, when we can add 1 for all numbers on segment, do it, while exist this is segment 3) end O(nLogn), and write easy

https://codeforces.com/contest/1157/submission/53393728

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

В этот раз, однако, див3 был сложноватый

»
5 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

1157D — N Problems During K Days can be solved simply by putting $$$1,2,\dots,k$$$ initially and then trying to put $$$(n-(k*(k+1)/2))/k$$$ elements in each, and then from reverse order adding as many elements in each position as possible, without considering special cases separately.

You can go through my submission for clear understanding.

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Anyone help me in finding the cause of TLE in Problem D in my solution.

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

This problem also has a solution like D:

https://www.codechef.com/SNCK1B19/problems/MAXPRODU

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Does anyone have a solution for problem E which does not involve STL structures, specifically without using multiset,set,map or multimap ?

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Problem D: "Then if nn != k — 1 or k = 1 then this answer is correct."

Any explanation for this ?

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

For problem 1157c1, what if the input is

7 7 4 5 6 3 2 1

The solution code out puts 5 RRRRL But if I discard 7 and take the subsequence [4 5 6 3 2 1],it's possible to get a strictly increasing subsequence of size 6, right?

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

When is the next div3?

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

What's wrong with my solution for problem B? https://codeforces.com/contest/1157/submission/53566680 I am getting wrong answer on test case 7

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I solved D in a different way. Mine

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I'm kind of late, but problem D can be easily (more or less) solved by binary searching the first element, and then binary searching every other element as well, from left to right, so that the minimum possible sum is <= n and the maximum possible sum is >= n. My submission

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

For the D problem, I just initialized array to 1,2,...,K then added (S — (K * (K + 1)) / 2) / N to every element in the array, and then just distributed (S — (K * (K + 1)) / 2) % N from the behind appropriately. Just wondering why there were so less submissions for this problem?

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

How to solve problem Minimum Array using segment trees??

  • »
    »
    5 лет назад, # ^ |
    Rev. 5   Проголосовать: нравится 0 Проголосовать: не нравится

    I solved with segment tree, so I will try to explain my solution:

    First we need to sort B array, to be able to find some index j for each $$$A_i$$$ such that $$$A_i + B_l \lt n$$$ for all $$$l \lt j$$$, and $$$A_i + B_r \ge n$$$ for all $$$r \ge j$$$. We'll have only one index j for each $$$A_i$$$, because $$$max(A) + max(B) < 2n$$$.

    After that we can divide B array in two parts and find the best among these greedly, using segment tree here to get minimum, and then updating the used element to not be taken more than once.

    Submission

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

can anyone tell me mathematical proof of E i just wanted to know why finding greater element is optimal than finding lesser value element if n-a[i] is not found

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    It is because for any $$$k\geq n-a[i]$$$ and any $$$0\leq b < n-a[i]$$$, you will have $$$(a[i]+k) \mod n \leq a[i] + (n-1) \mod n < a[i] \leq a[i]+b < n$$$.

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In problem E first I used a sorted vector to store the elements of array b and used lower_bound+erase operations to find the appropriate element for the current a[i]. But it gave TLE on test 16. But when I used multiset instead of vector it passed all the tests. Can anyone explain why vector solution gave TLE?

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    This is because erase function in vector works in linear time(n), but in set or multiset, the data is already sorted so it works in constant time.o(1).

»
16 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

i think i have better solution for D. We can search maximum value of c that sum of array(c, c + 1, c + 2 .... c + k) <= n; then we can run through this array from the end and greedily add 1 while the problem condition is being met. since we have to add a maximum of k units, we will be able to do this.

»
11 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

why don't solve using two pointer approach in problem C1?