Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Hi,

From now on, we are going to provide video editorials for Codeforces rounds. So, Codeforces rounds are not going to be limited to text editorials, but also video editorials!

We want to seek feedback and try to improve these video editorials as much as possible. We will try different ideas like recorded videos and livestreams to see which one helps you the best. So, please help us make a better content for you!

The blog will be shortly accessible in contest materials.

1986A — X Axis

1986B — Matrix Stabilization

1986C — Update Queries

1986D — Mathematical Problem

1986E — Beautiful Array

1986F — Non-academic Problem

1986G — Permutation Problem

I hope it helps!

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

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

Why

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

Kring

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

I believe text was much better for learning where you can take hints from each line and then work your way out to solve the problem.

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

you are handsome bro

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

why is not anyone solving d with dp i can not understood

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

    Because using dp, the order of computation can't be controlled. For e.g., 2*3+4. First, it will go in-depth and compute (3+4), then multiply it with 2. which does not comply with the precedence of operators. You got accepted because the minimum value will be achieved by multiplying (if it's 1); otherwise, performing addition. Multiplying by 1 does not change the result, so the order does not matter. I have ignored the edge cases when min 0 is achievable and n <=3

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

    I solved it with dp: 267111101

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

Problem E; wrong answer 5th numbers differ — expected: '118834745', found: '123022038' my code is failing this test case, can someone help me? i could come up with the entire solution on my own apart from the prefix and suffix sum stuff to find the element that needs to go in the middle, i'm struggling to understand how i would use prefix and suffix to find this element, can someone explain how it would work? I did it in a different way in my code but it's missing this test case-

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

    Oh for fucking love of god, please don't paste your shitty code like this.
    1. Use a spoiler
    2. Use the Code block feature that codeforces provides

    like this:

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

Video tutorials might be targeting certain group of individuals usually beginners and text tutorials might be concise and leave enough room for the individuals to think and figure why the solution works by themselves.

I think text tutorials are needed irrespective of video tutorials,

I presume vast majority of problem solvers prefer text tutorials ?

Let me know what you guys think.

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

    Video solutions are my last resort when I can't understand what editorial is trying to say / the approach is too unintuitive. Otherwise, I see no reason it putting link for a video here.

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

Thank you Shayan

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

My G's code is O(n^2) ,but it passed.

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

I did G1 through brute force, that is checking each for the condition. Resulting in O(n^2). Its failing at when len is around 30k+. Wanted to know whats the difference bw g1 and g2 problem?

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

I am working on https://codeforces.net/contest/1986/problem/E and got some interesting timing result that I cannot explain.

In short, I have two submissions, one accepted and another TLE, but I can't understand why the TLE version is slower.

The only difference between two submissions is that the accepted version sort the whole array once, and the TLE version sorts the bucket individually.

In principle, sorting the individual bucket has a time bound of O(sum (b log b)) <= O(n log (max b)), and it should be smaller than O(n log n) in all cases.

Local testing of sorting arrays by buckets or not does not show much difference, it could end up in many buckets, or it could end up with fewer but huge buckets, but the timing is more or less the same.

But in the submission, the timing difference is huge, the sorting by bucket version didn't complete in 2 seconds, but the sorting one version completed in 217ms.

This benchmark seems to show very similar timing:

import random
import time

l = list(range(1000000))
random.shuffle(l)

s = time.time()
l.sort()
buckets = {}
for v in l:
    mod = v % 1000
    if mod not in buckets:
        buckets[mod] = []
    buckets[mod].append(v // 1000)
t = time.time() - s
print(t)

l = list(range(1000000))
random.shuffle(l)


s = time.time()
buckets = {}
for v in l:
    mod = v % 1000
    if mod not in buckets:
        buckets[mod] = []
    buckets[mod].append(v // 1000)
for b in buckets:
    bucket = buckets[b]
    bucket.sort()
t = time.time() - s
print(t)

No way the difference in sorting caused a 10 fold timing difference. I also submitted multiple times to confirm it is not a glitch on the judge.

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

thank you for this! keep going