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

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

Hello, Codeforces!

We (KDOI Team) are glad to invite you to take part in Refact.ai Match 1 (Codeforces Round 985), which is the 8th CP contest held by us! You can view the previous rounds by us here.

  • Number of problems: $$$9$$$ ($$$0$$$ interactive);
  • Start time: Nov/09/2024 17:35 (Moscow time);
  • Contest duration: $$$180$$$ minutes;
  • Score distribution: $$$750-1250-1750-2250-2500-3000-3500-5000-5500$$$.

The problems were authored and prepared by Error_Yuan, _istil, Otomachi_Una and me sszcdjr.


A few words from our sponsor:

We’re Refact.ai, an open-source AI Coding Assistant, and on November 9th, we’ll be hosting our first round on Codeforces! Winners will receive valuable prizes, and all participants will have a chance to get some exclusive merch from us.

Refact.ai is pushing AI beyond simple code completion. Soon, we’ll launch the Autonomous AI Agent—a developer’s buddy that handles real engineering tasks end-to-end, from planning and coding to testing and deployment. You can read more about us in this announcement.

If you're excited about AI in software development and want to build the future instead of focusing on the trivial, join Refact.ai, founded by a former OpenAI researcher. We’re looking for talented Researchers and Backend developers to join our team.

Apply

Prizes:

  • 1st place: 500 USDT
  • 2nd place: 300 USDT
  • 3rd place: 200 USDT
  • 4-5th place: 100 USDT
  • Top 50 participants will get T-Shirts
  • Additionally, 50 random participants from the top 51-500 will receive a T-shirt

Good luck in the contest!


On the right, badges of the authors. From top to bottom, left to right are Error_Yuan, Otomachi_Una, sszcdjr and _istil respectively.

We would like to thank:

Good Luck & Have Fun!

UPD1. The Editorial was published.

UPD2. Congratulations to the winners!

  1. Benq
  2. jiangly
  3. hos.lyric
  4. Radewoosh
  5. arvindf232
  6. Nachia
  7. ksun48
  8. Szoboszlai10
  9. Endagorion
  10. _Serge_
  • Проголосовать: нравится
  • +655
  • Проголосовать: не нравится

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

As an author, I can confirm that no problems are authored by AI!

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

As a bot, I can't participate in this contest.

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

As a tester, I was really looking forward to participating in this sponsored contest, only to realize that I had already tested it.

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

As the boyfriend of the girlfriend of the tester Caylex, may you good luck & have fun!

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

The round's number "985" is special for chinese, especially for our students.

Hope you all can perform well in the "special" round.

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

As a newbie, I hope that I learn more in this contest.

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

The score distribution is scaring. I hope I can reach master in the contest.

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

As a tester, I might lose a T-Shirt.

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

I wonder what the tourist will choose: the chance to win money with the risk of losing their rating, or doing nothing at all?

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

As an author, I prepared $$$998244353$$$ problems and wrote $$$998244353$$$ pieces of editorial in all (modulo $$$998244353$$$).

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

Love the score distribution, 750 for A problem means 1 WA only cost ~ 7% score...

It'll be less painful for stupidity submission sometimes.

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

As a tester, there will be 0.3 problems about penguins.

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

24 points to expert ! lesss gooooooooo

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

Bruh C is worth 1750!!! Thats actually too much. I'm assuming it'll be wayy more difficult than usual.

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

As a tester,I'm a bot.

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

As a tester, I really like some of these problems.

For Chinese high school students, "985" is a special number. Wish everyone to get into the university of their dreams!

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

As a tester and the friend of the author sszcdjr, I can confirm that the authors are all not AI, because I can't solve any of their problems! GL&HF!

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

Just out of curiosity, what is the relationship between the score of a question in a contest and its difficulty in the problem set (https://mirror.codeforces.com/problemset). I know higher score questions are more challenging, but after noticing 2 questions with score ≥ 5000 and no questions in the problem set with this difficulty it made me realize its not a identity mapping between the two (that is difficulty(score) != score)

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

Is there Chinese statement?

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

Finally got the Tourist title :)

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

How come the badges of the authors are not related to their PFP I thought in CF badges come from your CF PFP.

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

Please reschedule, it's my birthday

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

Want to see tourist's rating change!

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

_istil What's the behind your badage ?

light ray ? physics ?

btw like it

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

Good luck!

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

rainboy vs 5500 points problem

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

this contest is rated? ;-;

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

Hope to reach CM in this contest!

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

So this contest is rated?

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

I think it clashes with COCI :(

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

Loved the '0' interactive phrase .

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

Good luck for everyone!

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

I think, contest will be interesting without interactive problems, (because I can't really solve it)

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

The contest is about to start in an hour, but only 17000 people registered!? Is this a special feature of Div1+2?

Last Div2 30000+ people registered, and this one is a Div1+2, shouldn't there be more people?

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

As a tester,Hanghang007 hanghanghanghanged

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

this is the hardest div

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

rainboy being RAINBOY !!

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

As a participant, I read all the comments!

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

c any hints??

edit : got it thanks

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

I spent 2 hours on C, yet did not solve it.

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

Prolbem E. Why this is WA21? (I can't resubmit now, and in submission there is junk code.)

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

wtf C, I'm so broken mentally, been doing cp for nearly 2 year still cannot solve C confidently, how this is even possible. god abandoned me

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

Why such a small number of participants? Only 7k+ solved A.

Edit: contest without subtasks feels so good.

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

How to do C?

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

Damn got cooked... someone explain C please?

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

Really enjoyed the problems. Great work authors!

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

Seems like some $$$O(3^n)$$$ passed H.Is it intended?

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

Looks like skipping C worked well for me, I solved A, B, D, E, F and then failed to solve C for about an hour lol

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

Any hints for F?

Things I could observe:

  1. If all edges have same colour, answer is clearly yes.

  2. If both $$$RR$$$ and $$$BB$$$ appear the answer is clearly no since there is at least one pair $$$(i, j)$$$ where all paths start with $$$R$$$ and end with $$$B$$$ and can thus never be palindrome.

  3. For simple alternating colours ($$$RBRBRB\ldots$$$), the answer is yes for odd $$$n$$$ and no for even $$$n$$$.

  4. The answer is no if an even length blocks of a colour appear more than once since there will be paths which are forced to start with $$$BB$$$ or $$$RR$$$ but can only have an odd number of the same colour at the end (example graph).

But I still have no clue how to generalize this to a solution.

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

I was trying to hack this solution during the contest — https://mirror.codeforces.com/contest/2029/submission/290747953

Can anyone tell me why this is not giving TLE for the case tc = 1e4, l = 1, r = 1e9, k = 1 sszcdjr

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

C>E

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

A construction similar to the one from problem D appeared at IMO 2019, problem 3. (But of course, it is a completely different problem.)

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

My solution for C:

dp[i][0] = the maximum answer up until i given that you haven't skipped any elements so far

dp[i][1] = the maximum answer up until i given that you are currently skipping elements

dp[i][2] = the maximum answer up until i given that you skipped some elements and are now back to not skipping elements

Transitions are annoying but its pretty much just casework. The final answer is max(dp[n][1],dp[n][2])

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

How to solve D?

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

simple code for C : 290735677

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

Why does this WA on D? I thought you just needed to get rid of cycles then it was easy

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

Can someone tell me how to solve B? I think I almost get it, yet I can't arrive at a full-fledged reasoning.

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

    replacing with a 1 doesnt change the count of 1s in s, but replacing with a 0 decreases the 1s. So if the count of 0s in r and 1s in s is same, the final bit in s (which is actually last element of r) should be 0. one more case is if count of 1s in s is just one more than the count of 0s in r, then the final element should be 1 (i.e r.back()) also as long as both zeros and 1s are there there will be atleast one adjacent different pair so we can ignore where to replace ezactly

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

    Note: there exists a $$$01$$$ or $$$10$$$ if and only if the binary string contains both $$$1$$$ and $$$0$$$.

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

C is like 4500 rated problem... I almost gave up on it at some point :)

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

Argh, I read B's statement wrong (thought that you to replace $$$s_ks_{k + 1}$$$ with $$$r_k$$$. That makes the problem waaay more difficult :(

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

Just saw some mf sharing solutions in contest time on YouTube

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

Seems like people are quite confused about C while it has a relatively straightforward solution:

Binary search the result x, and check if you can construct a solution whose score is x.

A solution needs some prefix + some suffix. You can calculate $$$prefix[i]$$$ = score as you get to position i, $$$suffix[i]$$$ = minimum score needed, starting from i, so that the score is x. Then you can calculate $$$min_suffix[i] = min(suffix[j], j \ge i)$$$.

The answer is valid if there exists i such that $$$min_suffix[i + 2] \le init[i]$$$: e.g. we take a prefix up to i, skip some elements, then take on a suffix that brings your final score to be x.

Of course you also need to handle the edge cases where the prefix or suffix is empty.

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

    There is an even simpler solution:

    • A higher score is clearly always better, so I store $$$dp[pos][0 / 1]$$$ = max score after the first pos contests with 0 / 1 indicating whether we've skipped a segment.

    • The regular (non-skipping) transition is a typical $$$dp[i + 1][j] = dp[i][j] + \text{(score change for current rating = dp[i][j] and performance = a[i])}$$$.

    • For skipping a range, its just $$$dp[i + 1][1] = \text{best prefix value of } dp[i][0]$$$ :)

    Code — 290717116

    I'm actually surprised so many people bricked on this problem, to me it feels like an extremely standard problem I'd expect to see in an Atcoder Beginner contest D or E.

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

Wtf is E? Something to do with least primes?

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

    You're on the right track.

    Hint 1
    Hint 2
    Hint 3
    Hint 4

    Code — 290740094

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

Check out neal's solution to problem C, you won't believe how simple it is.

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

C can be solved with 3 priority queues, without dp or binary search.

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

    explain please

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

      We have 3 states: before interval, in interval, after interval.
      Loop over the array with maintaining 3 max PQ (one for each state),
      in each iteration we do the following:
      1) update the top of the after interval PQ. (interval has been closed)
      2) push the top of the before interval PQ to the in interval PQ. (open an interval)
      3) update the top of the before interval PQ. (interval has not been opened yet)
      4) push the top of the in interval PQ to the after interval PQ. (close an interval)
      Finally, the answer is the top of the after interval PQ.

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

Anyone knows what's special about problem D test case 21?

I'm getting TLE and cannot reproduce it on my pc by generating random test cases

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

Glad to win one ninth of a T-shirt!

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

for F, let $$$s$$$ be the parity of the lengths of the runs of the color which doesn't appear in only groups of $$$1$$$ (WLOG, suppose it is red). I deluded myself into thinking about the problem as if every time you cross a blue, you always start at the left end of the corresponding red segment, for which I think the answer to the problem depends on whether $$$s$$$ equals any of its cyclic shifts

why am I regarded 🤣

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

i reached candidate master at this round ,finally div1

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

can anyone explain dp implementation of C. thankyou in advance .

»
18 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
for _ in range(int(input())):
    n = int(input())
    
    def f(a, x):
        return a + (a < x) - (a > x)
    
    dp = [0, -n, -n]
    for x in map(int, input().split()):
        dp[2] = max(f(dp[1], x), f(dp[2], x))
        dp[1] = max(dp[1], dp[0])
        dp[0] = f(dp[0], x)

    print(max(dp[1], dp[2]))

i did not understand f(a,x) it should return a + (a>x) — (a<x) can someone help

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

    That code uses some little-known feature of Python that bool is a subclass of int -- you can see isinstance(True, int) returns True. As a corollary to it, when a bool value is used in an arithmetic expression, True is converted to 1, and False is converted to 0. For example, 5 + True is 6 (!).

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

    variable names are reversed here compared to the problem statement. Swap a and x in the function f and it should make sense.

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

Thank you very much for the contest.

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

will i be contacted from recraftai if i had filled the form before the round and have got +79 rating points at the round?

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

Is the red text in I a correction of a constraint that was originally written higher or just emphasis?

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

Isn't this promoting cheating in a way?