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

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

Hello Codeforces!

mesanu, flamestorm and I are very excited to invite you to Codeforces Round 859 (Div. 4)! It starts on Mar/19/2023 17:55 (Moscow time).

The format of the event will be identical to Div. 3 rounds:

  • 5-8 tasks;
  • ICPC rules with a penalty of 10 minutes for an incorrect submission;
  • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
  • after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated
  • by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are an unrated participant/newcomer).

We urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism but to take part unofficially. Please do not spoil the contest for the official participants.

Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating unsporting behavior. To qualify as a trusted participant of the fourth division, you must:

  • take part in at least five rated rounds (and solve at least one problem in each of them),
  • do not have a point of 1400 or higher in the rating.

Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

Many thanks to all testers: jampm, Max_Calincu, KrowSavcik, TimaDegt, nyaruhodo, tibinyte2006, badlad, Phantom_Performer, AlperenT, Bakry, keta_tsimakuridze, Gheal, RedstoneGamer22, Dominater069!

And thanks to Alexdat2000 for translating the statements!

We suggest reading all of the problems and hope you will find them interesting!

Good Luck to everyone!

UPD: Editorial

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

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

What will I gain from hacking if there are no points?

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

As a tester, I suggest you participate! Problems are nice and educational!

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

I love div4 contest because i get positive delta.thanks for doing div4 contest!!!

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

I wish to see nice problems like other div4s

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

As a participant, I want to thank you for the contest!

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

What I was waiting for the most!

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

ooh div.4 . Means SlavicG in action :)

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

OMG SlavicG Round!

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

As GPT-4, tomorrow will be my 5th contest participation. I hope I become green :)

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

Going to be my first unofficial round.

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

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

Div 4

So, easily will do 80% of the problems.

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

As a tester, Give me contribution!

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

Hope to become expert in this contest.

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

Hope to see the colour change in this round !!
( Δ > +6 )

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

hello. i am man; i am from to mars and run away at abi abi is brother but not brother; abis isnt cool; int monkey; monkey = monkey + wepon; cout << monkey kill nuraly SH;

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

Hey, are you a contest? 'Cause you're looking CUTE!

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

I would smash this contest

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

Delayed round?

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

Starting time 10 mins. extended...

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

Div 4 contest, more like load testing for Codeforces Servers

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

the contest keeps getting delayed by 10 minutes for me? just me?

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

LateForces

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

More than 30k participants and now Codeforces is trafficked

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

Today i'm grey again..

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

DelayForces

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

Feeling like participating in onsite contest where after every refresh 10 minute increase.

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

Worst Server I Have Ever Seen!..

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

Div.4 is good for me~

»
4 года назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +11 Проголосовать: не нравится

May be, the queue more long than my imagination :3
 )

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

If there was going to be interactive problem.It should be mentioned in blog beforehead.

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

that long queue really sucks

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

QueueForces:(

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

In queue forces :(

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

There must be a prior information about Interactive problem in contest. i have seen several div 2 contest where author has given prior info about interactive problem.

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

I like the contest, but the website is not co-operating :(

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

I think it was supposed to be mentioned before the start of the contest about the interactive problem.

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

I'm praying to the universe this contest does not go unrated :)

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

Seems like Mike is manually judging solutions

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

I apologize for the long queue at the round. Today's round was a record in terms of the constant huge flow of submissions. Unfortunately, we ran into the speed of compilation. I already have plans to move the compilation somewhere to the cloud in such extreme cases. I plan to implement this for the next div4.

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

Interactive problem + long queue = nice COMBO!

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

The long queue has taken a toll on those of us who rely on proof by AC.

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

solving 1 (last problem took me more time than solving all the rest of the problems combined...

Due to WA and LONG WAITING QUEUE.

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

Lagforces...

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

Are pretests on hard version of G weak? I realized my code was doing the opposite of what I wanted it to do after submitting and it still got AC... I have no idea how my solution works.

»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

Bruh why did you let bitset pass G2?

UPD: I got hacked lol

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

Very hard to track if the submitted answer was right or not !!

A lot of time wasted there. Apart from that really very goooood contest.

»
4 года назад, скрыть # |
← Rev. 4  
Проголосовать: нравится +10 Проголосовать: не нравится

Любительский разбор задач

Разбор A
Разбор B
Разбор C
Разбор D
Разбор E
Разбор F
Разбор G
  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится +5 Проголосовать: не нравится

    Блин, клевый способ для G. Я решил жадно и сортировкой, но это прям рабочий такой способ! Спаисбо.

    Я уверен, что в разборе будет какой-то жадный способ, однако считаю, что для див. 3 и 4 разборы должны содержать именно вот такие решения как ваш разбор для G, потому что какие-то "элегантные" решения -- это, на мой скромный взгляд, самое трудное и, лучше приводить более рабочее решение, к которому можно трудно, но прийти. Нежели если я там на уровне интуиции и поверхностных доказательств буду сидеть 2 часа и рожать решение.

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

    Спасибо за разбор! Непонятно, как пользоваться этим bitset? Что делает операция bitset |= (bitset << c[i])?

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

      bitset<N> — набор из $$$N$$$ бит, каждый из которых может быть $$$0$$$ или $$$1$$$.

      bitset << k — побитовый сдвиг вправо на величину $$$k$$$. В терминах суммы, это прибавление $$$k$$$ во всем существующим суммам (индексам битсета).

      left | right — оператор побитового ИЛИ. Выставляет единицу по индексу [i], если хотя бы один из операндов left[i] или right[i] равен $$$1$$$, иначе $$$0$$$.

      Для bitset реализованы все побитовые операции. Рекомендую ознакомиться с его возможностями в туториалах в интернете и на cppreference.

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

    а почему О(n^2/32) заходит по времени? кажется что n^2/32 > 1e9. почему такая оценка не верна, из-за того, что побитовые операции быстро работают?

    • »
      »
      »
      4 года назад, скрыть # ^ |
       
      Проголосовать: нравится +6 Проголосовать: не нравится

      Константа низкая. У серверов Codeforces тактовая частота 3.6 GHz вроде. 3.6e9 тактов в секунду. Решение потратило всего 2.8е9 тактов. Предполагаю, что предсказуемое последовательное чтение из памяти, сдвиг, побитовое ИЛИ + предсказуемая последовательная запись в память это пара тактов процессора в среднем, тем более с включенным набором Ofast+avx, который подрубит 256-битные YMM или 128-битные XMM регистры в зависимости от предпочтений компилятора

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

How did I get G1 accepted and G2 WA with the same solution provided

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

Amazing Problems <3

I loved E because It was first time I solved an interactive problem.

Only if Queues werent that long I could have figured out my Idleness Limit Exceeeded 10 minutes before :(.

Solved everything except F

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

Contest over,still my solution is in queue :))

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

I am using prefix sum in G,why it is giving WA My solution

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

How to solve G2?

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

    if the kth element of the sorted array is less than or equal to the sum of all 0...k-1 elements then ok else no. iterate for all from 1 to n-1 (0 based) and sorted

  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится +6 Проголосовать: не нравится

    It is always correct to add numbers in increasing order. So you can sort a and there holds invariant: if a[i] > a[0] + a[1] + ... + a[i - 1] then there is no way to add a[i]. And if a[i] <= a[0] + ... + a[i - 1] then you can add a[i] and you can add for a[i + 1] any number from 1 to a[0] + a[1] + ... + a[i].

    So just sort and check that for each i a[i] <= a[0] + ... + a[i - 1]

  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится +7 Проголосовать: не нравится

    G1-G2 were easy when u observe that as we have the minimum unit as 1 so we can form any possible sum. So say we sort the array now following conditions should hold.

    • $$$a_0$$$ should be 1. (as it was initially given and not gonna change).
    • $$${a_i \ge a_0 + a_1 + ... + a_{i - 1}}$$$. (as if prior max subsequence can't form current number than it's impossible to make $$$a_i$$$)
    • »
      »
      »
      4 года назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      " when u observe that as we have the minimum unit as 1 so we can form any possible sum "

      Could you please explain how is it possible to form any sum?

      Although minimum unit is 1, but we need to make sure that intermediate values should also be there in a.

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

        As we are given, $$${a = [1]}$$$.

        • In the next step, $$${a = [1, 1]}$$$
        • In the next step, $$${a = [1, 1, 1]}$$$ or $$${a = [1, 1, 2]}$$$
        • In the next step, $$${a = [1, 1, 1, 1]}$$$ or $$${a = [1, 1, 1, 2]}$$$, or $$${a = [1, 1, 2, 3]}$$$.

        So by this, you can observe that in any way we can form the next number $$${1, 2, 3, 4}$$$ by choosing any above combinations.

        So via this, you can prove any next number is possible if the prefix sum is greater or equal to that number.

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

        You can prove it by induction. Lets say I can make any sum from $$$1$$$ to $$$k$$$ using the current numbers from $$$a_0,a_1,\cdots,a_i$$$. Then consider $$$a_{i+1}\le k$$$. Since I can make any sum already from $$$1$$$ to $$$k$$$, I can make $$$a_{i+1}$$$ and add it to my list of numbers, and now if I add $$$a_{i+1}$$$ to those previous sums, I can now make any sum from $$$1$$$ to $$$k + a_{i+1}$$$. However, if $$$a_{i+1}\gt k$$$, then notice that I can never make $$$a_{i+1}$$$, because the current numbers cannot make any sum greater than $$$k$$$.

        So if at any point $$$a_{i}$$$ is greater than the sum of the numbers before it in sorted order, the answer is NO.

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

    Simple solution: Sort array, go over each number and make sure its not greater than the running sum, unless the number is 1.

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

beautiful problems, even if i couldnt solve all i was manage to at least have a go at it. Perfect div.4 round

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

I got E and F but neither G1 or G2 somehow :'( also forgetting an extra print statement with this queue was really painful, but I guess that's just a skill issue.

nice problems though

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

Solution for F? I got TLE :D

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

    F was terrible enough!

    It was completely based on implementations. I myself wrote $$$696969$$$ lines of code.

    My submission

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

    I did it by check if (i2, j2) is along the diagonal the ball is currently moving and in the correct direction, otherwise move the ball as far as possible and flip the direction when it hits a wall.

    and to avoid infinite loops, if you've visited a certain position before and in the same direction, the ball will keep moving along this path and never reach (i2, j2).

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

      bruh I was iterating for each step, incrementing or decrementing i and j by 1, could have just taken it straight to edge/corner instead of each step, maybe that's why i got TLE. I thought it would pass the constraints.

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

        yeah that's definitely the issue since the constraints on the grid are (2≤n,m≤25000)

        the implementation is really long though, since you have to know which walls the ball could hit in the direction it's moving (which vertical and horizontal walls), find how far the ball is from those walls, move the ball the minimum of those distances in the right direction, find which wall the ball will hit first or if it will hit them both, flip the direction accordingly.

        the condition alone to find if (i2, j2) is along the diagonal the ball is moving in is pretty long.

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

PrefixsumForces

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

Good contest! Wasn't too fond of F though, so didn't do.

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

Waited 15min to get wa on test 1 (E problem).

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

went for a 20 min walk after submitting 3 questions with no response

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

For G2 and G1, after sorting the array I knew that that one of the conditions was that every element should be at max the sum of all the elements that occured before it. Little did I know that it was the only condition required. Could someone explain me why we can always make every number from [1 — sum of all elements occured] from the given elements ?

  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    We can prove by induction...

    Obviously it is possible to reach all numbers that are less than or equal to 1 by using 1. Then consider a time when we add a number j and the sum of existing elements is i. Assuming that all numbers up to i can be reached. Then all numbers from i to i + j can be reached by adding j to a number from 1 to i.

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

F will be an interesting (and definitely too hard for div4) problem if the constraints are n,m<=1e9 and no guarantee for their sum.

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

Why the following code for D is getting TLE? It has time complexity of O(n+q)

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

Even after many attempts , i am unable to remove "Idleness Limit Exceeded" to the problem E : 198257666.

Your help is appreciated.

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

Can someone please explain how to do problem D within time limits? And what optimization was needed for G2, i got G1 correct, sorted the array and checked if any element was larger than the sum of those before it, but TLE on G2 at test 19(coded everything in C)

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

What is wrong with my solution of D.?? Please look into it. https://codeforces.me/contest/1807/submission/198208523

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

please can someone tell me why is my solution to problem E giving WA on testcase 1? https://codeforces.me/contest/1807/submission/198264987

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

I see someone using correct way to do G2 but it hacked...

a[0] must = 1 for all 1 <= i < n, if a[i] > sum(a[0]~a[i-1]) then answer is NO. else is YES

is it wrong?

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

Problem E Flushing Problem what's the wrong with using '\n' always (Idleness limit exceeded on test 1), using endl (Accepted)

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

The problem F was not hard to understand but hard to implement. My guess is that there is probably a great implementation that does not require bunch of if and else blocks.

Can someone share a nice and compact implementation or the idea behind it?

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

F with simulation

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

How on earth Yodasen made possible to write solution and submit within the time interval of 5 second (solution A(3 min 53s) & D(3 min 48s)) and 21 second (solution C(7 min 30s) & G1(7 min 9s)) second!

Is this real??

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

For problem F, while contest I didn't read constraints properly, I designed more generalised solution. my solution will work for N <= 10^5 ( or even N <= 10^6 ) .

[submission:https://codeforces.me/contest/1807/submission/198280396] .

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

Hello, why is my code for problem D giving WA on test case 4? The logic should be correct and I cannot think of any bugs. Is there something I have failed to account for? There shouldn't be any issues with int overflow I believe.

Code

Thank you all very much in advance.

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

how is e related to dp???

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

    if you sort array, then:
    dp[i][s] = if you can make sum S using the first i elements

    base case:
    dp[1][1] = 1 (and check if a[1] == 1)

    transition is:
    dp[i+1][s] = dp[i][s] | dp[i][s-a[i]]

    Observation is that if some sum t can be created using first p elements, then it's also possible to create any sum <= t. So we can remove one dimension from the dp and store only the max s for which dp[i][s] = true.

    This is actually how my reasoning went during the contest.

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

      Can you prove this observation?

      • »
        »
        »
        »
        4 года назад, скрыть # ^ |
        ← Rev. 2  
        Проголосовать: нравится +5 Проголосовать: не нравится

        proof by induction:

        Define s[i] max sum that can be created from first i elements.

        It's true for i == 1, because a[1] == 1 and it's possible to create sum s[1] = 1 only

        Assume it's true for i, now prove that it's also true for i+1. If a[i+1] is greater than s[i], then the answer is NO, so assume a[i+1] <= s[i]. There are 2 cases. To create sum x <= s[i] we can do so without including current element, because it's already possible to do so using previous elements. To create s[i] < x <= s[i] + a[i+1] we can use current element, and create sum x - a[i+1] from previous elements. Creating sum x > s[i] + a[i+1] is impossible, because x - a[i+1] > s[i] and (by definition) s[i] represents maximum sum that can be created using first i elements. So s[i+1] = s[i] + a[i+1]

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

How does one become a tester?

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

Can anyone explain why am I getting TLE in the given code below.

https://codeforces.me/contest/1807/submission/198262166

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

    I am not sure but I think because the worst thing for your code to not find a solution for 1000 cases, in this case your complexity is $$$10^8$$$, but multiplied by many constants such as functions parameter and body, and so on

    Update

    I made a mistake above: the code will never reach to 10000 because you have visited array

»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +18 Проголосовать: не нравится

A small trick for Problem F

If you represent {DR, DL, UR, UL} as {0, 1, 2, 3} and have $$$d$$$ as direction variable, you can change directions easily

  • To change between $$$U$$$ and $$$D$$$, it can be done by XORing $$$d$$$ by 2, for example: ($$$d$$$ ^ 2)
  • To change between $$$L$$$ and $$$R$$$, it can be done by XORing $$$d$$$ by 1, for example: ($$$d$$$ ^ 1)
»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Are ratings changed yet?

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

когда будет системное тестирование?

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

Rating should be update before today's Div 2 round start.

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

Why are they redoing system testing?

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

I have a question related to Problem D. Odd Queries If the queries affect future queries. What would be the solution for this

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

I solved the problem D. In the contest, but After re-System Testing i get TLE :(

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

"Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you."

My rating was 706 before attempting the contest, and it hasn't been affected yet. Wasn't the contest rated?

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

..

»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -20 Проголосовать: не нравится

Solved the first 4 problems in 8 minutes and 5 problems in 17 minutes. Check the screen recording here https://youtu.be/HsGvOHmTwOw

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

why does problem 1807A - Plus or Minus have the "interactive" tag?