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

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

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
  • Проголосовать: не нравится

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

Why

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

Kring

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +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.

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

you are handsome bro

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

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

»
22 месяца назад, скрыть # |
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-

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 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
»
21 месяц назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

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

I am working on https://mirror.codeforces.com/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.