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

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

There will, and there shall be a THU round!

Nihao Codeforces! After the unfortunate event which led to Codeforces Round 1010 (Div. 1, Unrated) and Codeforces Round 1010 (Div. 2, Unrated) being unrated last week, we’re back and stronger than ever!

Tsinghua University’s Student Association of Algorithmic Competitions (THUSAAC) is pleased to invite you to participate in Codeforces Round 1012 (Div. 1) and Codeforces Round 1012 (Div. 2) on 23.03.2025 08:35 (Московское время). This round will be RATED for everyone. You will be given 2 hours and 30 minutes to solve 5 problems for division 1 and 6 problems for division 2, and two of each will have subtasks. Note the unusual time of the round.

Our team of amazing problem setters include: Iam1789, Ecrade_, E.Space, QuietBeautifulThoughts, gyh20, SpiritualKhorosho, dapingguo8, myee, abruce, _Lucien. Some of the problems prepared were not used in the final contest but we would still like to thank them nonetheless.

We would also like to express our gratitude to the following individuals:

THUPC is an annual event hosted by Tsinghua University’s Student Association of Algorithmic Competitions. It is the largest student-run competitive programming contest in China with the top 100 Competitive Programming teams from all over China coming onsite to vie for the crown of BEST CP Team in China after qualifying from a pool of 1000+ teams.

We hope you will enjoy and have fun in the contest. Good luck.

UPD: Here comes the scoring distribution.

Division 1:

$$$750+(1000+500)+(1000+1250)+2500+3000$$$

Division 2:

$$$500+1000+1750+2000+(2000+1000)+(2000+1500)$$$

UPD2: Congratulations to the winners!

Div.1:

  1. tourist

  2. ecnerwala

  3. jiangly

  4. ksun48

  5. JDScript0117

Div.2:

  1. liudiao

  2. lnw143

  3. ilovelll

  4. boboquack

  5. Madeeyuth

UPD3: Editorial

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

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

based

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

Hope you all enjoy our contest :)

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

hope the contest will be held successfully this time :D

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

As a participant who has taken part in the preliminary contest but failed to enter the finals, I will reach CM again in the contest.

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

thu rounds, best rounds!

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

As a participant, I hope the problems are cool!

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

Auto comment: topic has been updated by fengzhengwei (previous revision, new revision, compare).

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

Cool!

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

expecting a good round

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

I hope it goes well.

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

orz fengzhengwei

I am your biggest fan!

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

THU never makes me disappointed!

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

It seems that I got another opportunity to participate in Codeforces with pay while on the job.

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

Where is the score distribution?

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

The revengers ARE BACK LoL

This could be the surprising second opportunity to achieve an academic link with Tsinghua University throughout my life even if I'm in mainland China

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

Isn't the number of testers of this round quite low? Especially for a div. 1 round.

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

Score distribution?

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

please add scoring distribution

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

Hopefully, this round will not be postponed and then unrated at the same time like the last unusual scheduled round...

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

Are the questions sorted by difficulty?

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

Auto comment: topic has been updated by fengzhengwei (previous revision, new revision, compare).

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

Auto comment: topic has been updated by fengzhengwei (previous revision, new revision, compare).

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

Waiting for guests to leave so that i can attend the contest ;sob

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

The best coders in the best university in China can NOT EVEN COUNT THE EXACT NUMBER of problems.

Sad.

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

first time div.1!

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

Auto comment: topic has been updated by fengzhengwei (previous revision, new revision, compare).

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

hard c

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

Good luck everyone, glad we can have a late night contest.

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

extra registration please?

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

why can't i register omg :sob:

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

Is there no extra registration?

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

What if I forgot to register? Can I still participate?

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

extra registration?

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

is C correct?

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

Why where is no extra registration?

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

Why no extra registration and also registration closed at 11:00 and contest started at 11:05. I wanted to participate :(

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

Why is there no extra registration? I wanted to participate :(

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

As an onsite contestant, the lunch is McDonald's and they provide better meal than Zhili Cup(which is 1+1=13.9 combo).

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

how does my C run in 78ms :D ?

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

Um, I feel bad about D1 A.

The limit $$$\lfloor \frac{n}{3} \rfloor-1$$$ misled me.

When I saw the limit, I considered dividing the permutation into $$$\lfloor \frac{n}{3}\rfloor$$$ groups with size $$$3$$$. That wasted much time.

But the true answer is around $$$\lfloor \frac{n}{2}\rfloor$$$.

If the limit is $$$\lfloor \frac{n}{2}\rfloor-100$$$, I can solve the problem much faster.

Did there anyone have the same experience as mine?

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

D surprisingly easy, could've swapped place with C.

C easy on the logic, but hard on the implementation (or I'm just over complicating things).

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

Div2C today = implementation skill issue.

WA/TLE/RTE for no real reason, oh well...

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

Wow I hate 1B

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

Why can't I see others' code?

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

Is it just me or in div. 2 D felt easier then C?

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

any tips for c?

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

tho I lost expert, but I loved problem C for some reason. especially after getting one the fastest solutions for the problem

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

C2 is very nice, but unfortunately I thought of wrong solution and spent half contest implementing..

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

Become IGM probably. I've come up with the solution of C2, but it's too hard for me to implement.

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

Is C not meant to be solved by maintaining tables and the count of people sitting at a table? I used a std::set<std::array<int, 3>>> and suffered TLE

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

    Dont go for n*n Try around (sqrtn +k)*(sqrtn+k)

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

    the order can be pre-computed. Note that in a table if we know the distance for the bottom left cell of a table, then we can calculate further distances like this

    d + 1 | d + 4
      d   | d + 1
    

    where d is the distance of bottom most cell. now the order will always be in diagonal order (draw to note this).

    the only exception will be the top right cell. if we consider the table above the current table in the next level diagonal, then the top right cell of current table comes before the bottom right cell of that table. knowing this, we can pre compute orders and then simply place the people

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

After solving B2, I accidentally submitted it to B1, so my total score for B1 and B2 ended up being lower than before submitting... (early B1 > late B1+B2). Sad lol. (Mistakes like this are irrecoverable, right?) Fortunately, it looks like my ranking didn't change.

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

Sorry but how did the statement of D1C get approved?

The statement has critical information spread between utterly irrelevant story lines to the point where its extremely irritating to read (at least for me).

I understand that the problem setters sometimes want to associate a story with a problem, but on CF its usually:

  • Natural and short (1-2 sentences) enough that it works as the problem definition.

  • Added as a paragraph before the formal definition so that you can skip past it.

This statement does neither of these. Instead you have utterly useless lines like To remind the correspondence, M's mother adorned each key with a gemstone of a different type. between actually critical information that makes the reader think this will be relevant to the problem when it isn't in the slightest.

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

codeforces

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

Setters, literally messed up with problem c there,

  1. first of all, problem statement had a fatal mistake for interchanging values of t = 0 and t = 1
  2. problem statement did not mention what does distance to table means, later it was stated in announcement
  3. announcement also had mistake -

it stated — For the fourth guest, distance to cell (1,4) is 4, so they chose it, For sixth guest distance to cell (1,5) is 6, does that even make sense!

they later fixed this 6 to 5. Making mistake while correcting a mistake in a round with 10 >= master level setters sets me low :(

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

In Div2C, can someone please explain, why we place on (1,5) and not (2,2) ?

Aren't we simply taking Manhatten distance ?

For the sixth guest, the distance to cell (1, 5) is 6, the same as to cell (2, 2), but since the x-coordinate is smaller, they choose it.

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

2C wasn't explained well, lost a lot of time because of it

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

Has tourist achieved Rank 1 this time ?? Finally #2 curse broken !!

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

Yet another speedforces round. Failed to get to IGM :(

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

How to prove Div1A? I just guessed a solution of doing the following three conditions repeatedly which got AC:

  1. If there is a value which will result in the smallest remaining prime, do so using the smallest such value.

  2. If all numbers overshoot the prime, then increment the smallest prime.

  3. If all numbers undershoot the prime, then just put the largest remaining value.

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

Great contest! But the statements could be more clear.

  • A: Decent number theory A, exactly at its place
  • B: Slightly unclear statement about pushing the balls, I had to spent some time to figure out why the last testcase was "NO"
  • C: I believe the distance definition turned out to be unclear. That is, there was no definition of distance at all. About the problem, I thought at first that the tables would tile a square. After WA I figured, that the triangle would be optimal, not square, so there was a plot twist!
  • D: The first problem that I solved by coding different approaches first. I'm kinda curious now if I could've solved it developing a math model first.

Sadly, there were not that many participants as usual. I randomly got enough sleep today, woke up quite energetic and participated in the morning contest at my timezone. And I don't regret it!

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

bad statement.

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

I passed simulation with bitsets in Div1B, basically maintaing bitsets of non-zero elements of both arrays, and every time only perform operations on such indices where both $$$a_j \gt 0$$$ and $$$b_i \gt 0$$$ (finding so by doing AND of bitsets). What is an asymptotics of maximum number of operations that can be done by this solution (by operation I mean substracting non-zero from $$$a_j,b_i$$$)? Is it something reasonable, or I was lucky?

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

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

I read div2 c completely from the announcement

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

Hey, can anyone proof my div2 D, just luckily got AC after 10 pen ToT.

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

How to solve Div2 E1 ?

I wrote a brute force solution but it got TLE on test 25 :(

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

Tanks for making this unrated. I'm sure there's a lot of people who got stuck on C.

Also, a stupid question, was the ceiling sign always there?

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

Weird constraints of B.

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

Reading 1C1/2F1 be like, am I taking somewhat english reading comprehension exam right now

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

There is a whole paragraph in D1C :skull:

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

problem D , find a prime number p in ($$$n / 3$$$ , $$$2n / 3$$$) (guaranteed there exists a prime) . Now put $$$p - 1$$$, $$$p + 1$$$ , $$$p - 2$$$ ,$$$p + 2$$$ , ..... and place remaining numbers. At sufficient number of even positions we have $$$c[i] = p$$$

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

Congrats! 8th grader JDScript0117 gets 5th place in div1 !!!

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

This contest was so wack for me, missed B and C and solved in A -> F1 -> D order then was too slow on C.

I guess the fact that C,D,E1,and F1 are all within 250 points of each other makes for a weird dynamic since there's a real strategic decision to go for certain tasks first since they're all supposedly nearly same difficulty according to point spread but at the same time it's weird to be 1600 and somehow miss a Div2B and Div2C just simply because this round gives a lot more options than your usual CF round.

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

As participant, I hope I don't see these kinds of contests in the future

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

Can someone please tell why does this get tle how do i optimise this solution

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

Is anyone able to determine why my submission for Div2C: 312026477 is wrong?

My logic was to use two priority queues to maintain available seats, one for the 1s and one for the 0s, then when a 1 enters, ensure that the first available seat in the pq wasn't already taken by a 0 previously. I couldn't get past pretest 2.

I had also defined a custom comparator to order the seats appropriately based on Manhattan distance.

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

DIV2 B can someone check why my code getting WA on TCase 4?

Logic was if arr[i][j] == 1 and either there is a 0 on top of it, then there should be 1s continuously appearing to the left of it and if there is a 0 on the left of it, continous 1s should be there on top of it (starting from the 0th row).

312042843

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

    You are missing the case when both left element and upper element are 1's.

    check this case out :

    3 3 010 111 011

    The 1 at (3,3) is assumed to be valid according to your code but it isn't.

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

Can someone try to hack this

I just find next alive b for each ai, but i think it's possible to chain ai's with bi's and force the solution to be n^2

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

    Hey it's provable that it passes. consider the set of good indices as indices in array A and array B that are non zero. (so initially there are 2n such indices)

    and the round indices are the set of good indices that change in round r.

    now since you maintain a set you're only visiting the good indices in the round r and kill at least half of it. (at least one from each pair for the current round)

    since there are only 2n indices to kill your solution doesn't make more operations than 2n!

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

      how do you take into account the case when he pops some {$$$ai, bi$$$} but that $$$bi$$$ was already $$$0$$$ so he just changes the $$$bi$$$ for that $$$ai$$$ and pushes into set again. Can you prove that these reattachments will be bounded by $$$O(n)$$$ and not go $$$O(n^2)$$$ (which I believe was his main confusion).

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

I have attempted 'D' and reached the 8th test case before getting a WA due to a permutation issue. Still, I’m happy that my approach successfully passed the first 7 test cases in one of the contest’s highest-scoring problems!

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

As someone who skipped school today -18 rating isn't what I expected.

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

I love THU round! XD

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

div2.D is a really tricky problem.

I used 1h time to think about random algorithms(that is because I used ramdom_shuffle() to solved div2.C before).I also used 30min time to think about why the 2,1,3,4,5,···,n was wrong.Almost the end,I thought about the correct solution.

PS:the samples are very confusing,I believe many people tried the 2,1,3,4,5,···,n first and got WA on test 8.

If you think I am wrong,don't downvote please

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

In Div.1 E, accroding to validator, sum of N is guaranteed to be less than 80. And its not shown in the statements.

If the validator was corrected to fit the statement, only jiangly's code will be able to pass (125ms *10 = 1250ms), among all 4 accepted codes till now.

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

When/where editorial?

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

My solution for B: For every row and column count blocks of '1' which should either be 0 or if 1 should be tied to the beginning of the row or column for a valid insertion of balls in the row or column. Finally, go through the grid again and wherever a ball is present check if the insertion of balls is valid or not along the row or column. Answer should be 0 if found invalid along both ways. Is this wrong or is my code wrong? code

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

Damn, the problem statement of d2c is so hard to understand.

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

Hi, when will the editorial be posted?

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

I need tutorial.

qwq

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

When solution? I really want to know how to solve 1B / 1C though I didn't participate it

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

    Div1 C1 is a nice problem; I actually solved this in contest but the idea was unfortunately too slow to extend to C2. While you're waiting on the official editorial, here's a quick hint for C1.

    Hint 1
    Hint 2
»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

When is editorial coming out

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

how to DIV2 C?

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

Hi. Are you planning to release an editorial soon ?

Can someone explain div2 E1 and E2 ? please :D

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

    You want to find out in which operations there are some non zero values in a matched with non zero values in b. At most you can have 2n of this instances since every time there is a match at least one number becomes 0.

    You can do this by keeping a set of active (non zero) aIndexes and active bIndexes, you also have an offset which represents the current offset of the aIndexes. Now you calculate the necessary offset for each active aIndex to meet with an active bIndex (using binary search in logn). Next, in each update you go the next offset which gets you a match and if the a that match remains non zero you look for its next matching active bIndex.

    For E2 you can do almost the same thing, you only need to also keep track of the sum of all active 'a's, and stop when their sum becomes equal or less than k.

    Here's my code 312026398

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

Where is the Tutorial?

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

In Div2D, I solved it by picking a prime $$$p$$$ in the range $$$\frac{n}{3} \lt p \lt \frac{2n}{3}$$$ as the first number and then alternating as:

$$$ p-1,\; p+1,\; p-2,\; p+2,\; \dots $$$

Proof:
Case 1: If $$$\frac{n}{3} \lt p \le \frac{n}{2}$$$, then

$$$ c_i = \left\lceil \frac{S_i}{i} \right\rceil = \left\lceil \frac{i\cdot p - x}{i} \right\rceil, $$$

with $$$x \lt i$$$ ensuring $$$\lceil c_i \rceil$$$ remains prime for several steps (until $$$p-x \lt 0$$$). Since $$$p \gt \frac{n}{3}$$$, we get at least $$$\frac{n}{3}$$$ primes.
Case 2: If $$$\frac{n}{2} \lt p \lt \frac{2n}{3}$$$, then

$$$ c_i \text{ is prime until } p+x \gt n \text{ or } x \gt n-p. $$$

Since $$$p \lt \frac{2n}{3}$$$, we have $$$x \ge \frac{n}{3}$$$, yielding at least $$$\frac{n}{3}$$$ primes.
Does this look correct? Also, is there a way to maximize the number of primes in this construction?

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

    Here's the closest to optimal as possible as I can find:

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

Still Waiting for the tutorial.

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

I recently got a notification that my Codeforces solution 312004364 for the problem 2090D coincides with others, so I just wanted to clear things up.

When solving the problem, I referred to some code I found online(https://www.geeksforgeeks.org/minimum-absolute-difference-of-a-number-and-its-closest-prime/?ref=ml_lbp) with minor adjustments to understand the approach better. I didn’t think much about it at the time, but I now realize that since others might have used the same sources, it ended up looking similar. Definitely wasn’t my intention to copy or break any rules. Note: I made some changes to the code referenced above after its understanding. So , I assure you that such similarity arose purely due to coincidence. I hope everyone understands.

I will make sure to write solutions more of my style going forward. Lesson learned definitely.