Sanae's blog

By Sanae, 5 months ago, In English

你好,Codeforces!

We (WDOI team) are delighted to invite you to participate in Codeforces Round 1098 (Div. 2), which will be held on May/16/2026 17:35 (Moscow time). You will be given $$$6$$$ problems, including two problems each having easy and hard versions, and $$$2$$$ hours and $$$15$$$ minutes to solve them. This round will be rated for the participants with rating lower than 2100.

The problems are authored and prepared by Sugar_fan and me.

The score distribution:

A B C D E F
$$$500$$$ $$$750$$$ $$$(1500+1000)$$$ $$$2500$$$ ($$$2000$$$ + $$$1500$$$) $$$3500$$$

We would like to express our sincere thanks to the following individuals for their contributions and for making this round possible:

We are a team made up of fans of both competitive programming and the Touhou Project. Although this isn’t our first time hosting contests on Codeforces — we previously organized Codeforces Round 796 (Div. 1) and Codeforces Round 796 (Div. 2) — I authored most of the problems in this round with little assistance. In 2022, most of our members were Olympiad in Informatics (OI) participants, but over the four years since then, many have stepped away from OI and competitive programming. While the older generation may eventually fade away, newcomers like me aim to keep our community alive by injecting fresh energy and passion into what we love. I hope this kind of pure love persists and carries on.

Across these six problems, you will meet characters with their own distinct personalities and beliefs.

Marisa stole Reimu’s takeout and vanished before the shrine maiden could react. Hungry and sharp-eyed, Reimu marched to the Scarlet Devil Mansion, challenged Remilia to a fierce game of Hisoutensoku, and claimed victory—along with her lunch. Near the Misty Lake, Cirno found a cold number frozen in the ice. With a child’s certainty, she reshaped it into a beautiful ice crystal, perfect and gleaming. Atop the Youkai Mountain, Sanae watched the stars and prayed for fortune, her quiet hopes rising with each passing light. Elsewhere, an Amanojaku teetered on the edge of ruin. In Yukari’s contest, it solved a problem others deemed impossible, reversing its fate and reclaiming its place.

Hearing of these scattered lives, Momoyo built a grand network across Gensokyo — linking shrines, mansions, and factions. Conflict gave way to conversation, and peace settled softly over the land. Harmony replaced trouble, and laughter returned to the air.

Help them overcome these trials through your logic, and find satisfaction in lending a hand. We hope you enjoy the round. Good Luck and Have Fun!

May Gensokyo’s peace endure — and may the real world, too, know such days.

UPD1: Tutorial

UPD2:

The top five (official):

  1. the_chill
  2. nguyenphong233
  3. oleinikowc
  4. edmondium23
  5. mo_mo_yu

The top five (unofficial):

  1. the_chill
  2. nguyenphong233
  3. oleinikowc
  4. maspy
  5. edmondium23

The first solvers :

UPD3: Apology

  • Vote: I like it
  • -131
  • Vote: I do not like it

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +15 Vote: I do not like it

Same task arrangement as the last full-cf div2 round!

I like that and hope to become master again awa.

Good luck to everyone!

»
4 months ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

As TheWorse, I will become the worst of this round. And future rounds.

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +8 Vote: I do not like it

As a fan of yiren, I will be in my wheelchair in this round.

»
4 months ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

As a tester, I enjoy watching you suffer.

»
4 months ago, hide # |
 
Vote: I like it +28 Vote: I do not like it

As a tester,wish you good luck and enjoy the contest! Kochiya Sanae is so cute!!!

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +38 Vote: I do not like it

As a tester, I hope you can possess the same wisdom as Cirno to solve these problems.

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +11 Vote: I do not like it

Sometimes I feel like changing my profile picture to anime girl is my missing piece to improve.

»
4 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

As a tester, I am a tester!

»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Manifesting postive delta for all.

»
4 months ago, hide # |
Rev. 2  
Vote: I like it -9 Vote: I do not like it

As a participant, trust the Chinese

Spoiler
»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

As a tester,I tested.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I'm a member

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

is this genshin impact?

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

While the older generation may eventually fade away, newcomers like me aim to keep our community alive by injecting fresh energy and passion into what we love. I hope this kind of pure love persists and carries on.

»
4 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

why does she hold a shovel? what does it have to do with wind

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As a potential participant, I potentially participate.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As the statement writer for the last WdOI round, I look forward to reading new fancy Gensokyo lore.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why no interactive problems? I love interactive problems!

»
4 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

As a participant, I will observe other people solving F.

»
4 months ago, hide # |
Rev. 2  
Vote: I like it -19 Vote: I do not like it

.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

i'm very intersted

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can you bring it to Luogu?

»
4 months ago, hide # |
Rev. 2  
Vote: I like it -10 Vote: I do not like it

I'm interested.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

good luck to everyone. peace <3

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope I can solve at least one problem to get some rating... and to enable myself to write blogs (and catch cheaters).

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone explain what does 1500+1000 means in question c.

»
4 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

Is that AI-generated art? Ugh

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As a newbie, solving B would already make my day lol

»
4 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

As a participant, let's go

»
4 months ago, hide # |
 
Vote: I like it +17 Vote: I do not like it

Why so loooooooooooong queueueueueueueue :-(

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

as a tester and a student suffering from midterm exams, wish everyone good luck!

»
4 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

aaaahhhh !!! ... queue too slow

»
4 months ago, hide # |
 
Vote: I like it -14 Vote: I do not like it

Queueforces during the contest again... and again...

»
4 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

kiram to kos nane jendat madar kosde ye pedar kiri

koskesh kiri in che anie khar kosde

soalaro az to konet dar ovordi ?

»
4 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

I am stuck, I am in WAforces

»
4 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

C is too hard for me. I have tried 10 times. But all the result is wa 2

»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Why was D 2500 points?????

»
4 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

The problems stay in the queue for a very long time, and that affected my performance badly from the very beginning of the contest.

Besides that, Problem B was basically just printing the answer — there was no real work involved. Most people probably got wrong answers because of some corner case. Honestly, I don’t see much value in a problem like that.

Bad starts have a huge impact on performance throughout the entire contest.

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it -12 Vote: I do not like it

    I think there was no work involved for you but many people like me it was a learning. I was unable to solve it. Its discouraging to see your comment. I dont think the author's are stupid enough to give a print answer question. You got to get the answer to print answer and many people struggled on problem 2 until it clicked for them.

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      First of all, I don’t care about your struggle. Secondly, you already submitted the correct solution in 11 minutes, but if you had changed the condition to: n <= 3

      you would’ve gotten Accepted. So your mistake was because of a corner case too.

»
4 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

not sure if it was intended, but example test cases were very useless

»
4 months ago, hide # |
 
Vote: I like it +49 Vote: I do not like it

CornerCaseForces :(

»
4 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

I felt it was kind of an easy round?

$$$A$$$ and $$$B$$$ were pretty easy. $$$D$$$ was kinda a common idea.

$$$C1$$$ and $$$C2$$$ genuinely gave me a headache, but the idea was simple though.

»
4 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Some feedback:

  • C1 and C2: trivial to mindsolve but implementation-hell
  • D: too standard, and I don't understand why the time limit is so tight
  • E1: beautiful, I really liked it
  • E2: I think this can be solved with 3d mo's? it would be crazy to implement though
  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    How would you do 3d Mo's here? you can do it with a segment tree which holds 8 values per node and it works, but the implementation is hell on earth

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +8 Vote: I do not like it

Honestly, getting past B, C1, C2 was so fckn difficult. I'm still not sure I'll pass tests on them. Tight constraints on D as well.

»
4 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Loved the contest! TL too tight on D tho

»
4 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

I was really astonished when I see problem C appears in Codeforces. The style is so special in Codeforces...

»
4 months ago, hide # |
 
Vote: I like it +63 Vote: I do not like it

Ragebait contest

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

so hard B :/

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Bro mistakenly set the questionnaire of Div 1. :(((

Hardforcess

»
4 months ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

implementation hell...

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Waiting for editorial..

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hello! I have a question regarding B. Suppose you have the 2 placed such that on both sides the number of free position is equal ? Is the answer then not k + min(dist,n-dist) — 1 ? The -1 comes from: She stays, he moves towards her, then she starts moving the other way, so in the k he gains 1 distance to her, hence it should be less. Let me know !

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    same doubt,,i did that got a wrong sub,, changed it to the basic case and it passed

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it

    case n = 2 and n = 3

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    In the case that there are only 2 or 3 positions in the circle, the answer is always 1 since every node is adjacent to every other node.

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    If she stays still, she doesn't spend any moves, she still has k moves left.

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Ohh, this might be it. I didn't realize this and yes that's why it works. Thanks a lot!

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    if in the first second, he moves towards her. Then for next k second it will continue to maintain the same distance. (He comes close, she goes away). after moves ends, now he will have to cover dist — 1 more. if k <= 3: then it will end in the first second

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    For example x1 at position 2 and x2 at position 5, with n = 6 and k = 2. I would say the answer is 4. She stays, he moves to 3 in 1s , then she moves to 6, him to 4 in 1s, then he goes to 6 in 2s. Total is 4 which is 1 less than k + min(3,3).

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    k is the number of total moves. If she stays (doesn't move) it is not counted a move

»
4 months ago, hide # |
 
Vote: I like it +46 Vote: I do not like it

whoever made c

never cook again, impl hell isn't fun please remember that

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

C1 TLEforces

»
4 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

weaksampleforces

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Any hints for E1?

»
4 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I rarely give contests But when I give contest it be like :

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +6 Vote: I do not like it

I don’t know what the point D has 2e6 input, I know author want to hack O(n lg n) solution, but making n 2e6 only make the bottleneck be input, and force users to use fast read, which is meaningless. Author can make alternative way, like given a random generator and let user generate the points by themselves.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why do I even have to rewrite my C++ solution into pure C just to pass Problem D’s time limit?

»
4 months ago, hide # |
 
Vote: I like it +22 Vote: I do not like it

corner case contest :/

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Please make the TL for problem D bigger and rejudge the submissions. The TL is too tight, to the point where the bottleneck seems to be input processing. Implemented it in O(N) but still got TLE.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I had a stupid bug in C2 because I didn't pay attention that n could be equal to 1. I didn't manage to find it till the end of the contest. Sadge.

»
4 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

C was a nightmare

»
4 months ago, hide # |
Rev. 3  
Vote: I like it +16 Vote: I do not like it

My initial rating was 2098. I originally hoped to reach Master after this contest.

But, I got stuck by numerous corner cases on problems C1 and C2, resulting in six consecutive WA on pretest #2. This directly led to my poor performance, and I feel really upset about it.

In addition, I think setting the upper limit of n in problem D to 2e5 would be the most appropriate. Making n ≤ 2e6 only forces us to add a bucket sort on the standard solution, and I really don't understand why the problem setter chose to set n up to 2e6.

»
4 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

corner case forces :|

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I lose the score badly because I don't know "llabs()" at C1 and C2…

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Because of many details, I submit wrong answer eight times. These scary details make the round terrible.

»
4 months ago, hide # |
 
Vote: I like it +25 Vote: I do not like it

You say you want to carry on the "pure love" of that passion.

But which I see is you are just stealing others love of CP by setting such ragebait problemset.

»
4 months ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

TIME LIMIT EXCEEDED ON TEST CASE 19-forces

»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

goodbye expert

»
4 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

This is by far the worst Codeforces round i participated in. 0% problemsolving 100% debugging. Both B, and C just consisted of considering the edge cases correct.

»
4 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

CornercaseForces

»
4 months ago, hide # |
Rev. 8  
Vote: I like it +4 Vote: I do not like it

.

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Maybe because of specially odd Problem C, TLEForces of Problem D(I didn't finish that, I just heard from others) and queueueueueue-forces at the beginning at least 30 minutes of the contest...

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    It will soon become negative(

»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Worst contest I have ever participated in, by far. So bad, it compelled me to make my first comment. Really upsetting.

»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

The purpose of setting problems is to torture the contestants.

»
4 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

Unpopular opinion but ppl complaining about debugging, corner-cases and hard implementation should probably work on those things rather than blaming the author

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +9 Vote: I do not like it

Cornercaseforces

»
4 months ago, hide # |
Rev. 2  
Vote: I like it +15 Vote: I do not like it

Positive thinking, C1 and C2 are good practice for debugging. Test cases are easy to generate and naive solution is quite straight forward to implement.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

long queue,corner case,the cn round is too bad,I only solve 1 problem,it makes my rating -150

»
4 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

Two question.

Why C appears in Codeforces?

And why n in D approach $$$2 \times 10^6$$$?

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Sorry.

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Could you explain the trouble in C?

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      There're many corner cases while example isn't intensive enough.

      • »
        »
        »
        »
        4 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        However, the problem is right and it's can be implemented easily.

    • »
      »
      »
      4 months ago, hide # ^ |
       
      Vote: I like it +16 Vote: I do not like it

      For me, I didn't like that the difficulty came from implementation and considering casework rather than an insight or observation (I'm doing codeforces for the latter!). C1 was completly unnesary because you either code a braindead bruteforce which doesn't belong on this site or solve C2 anyways. You could also have reduced many people's frustrations by adding a requirement like "your answer must have the same number of digits as a", focuses the problem on the idea of matching prefixes and less on casework.

»
4 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

why C>>D

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Holy Reference

»
4 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

insane amount of cheaters in the top 100s

»
4 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Please don't worry about the positive comments.

»
4 months ago, hide # |
 
Vote: I like it -12 Vote: I do not like it

A bad round!!!!!!!!!

»
4 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Time limit exceeded on pretest 19 and Wrong answer on pretest 2-forces

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

why C>>>>>>>D :(

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can anyone spot the bug in this code(or any counter-example)?

Code

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone help me out i am stuck in problem C1.

My code in C++

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

cnm

»
4 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Proud to be the first solver of problem A. Enjoyed the problemset, hope to see more from the WDOI team!

»
4 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

For the problem B the Pretest 2 test number 10 The test is

4 1 3 1 and the answer should be 2 and not 3 as we can't increase the distance if min_dist is equal to n/2. Please tell me if I am wrong

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

?!strongstrong?!

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

A,D 800,B 3500

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Asia round!!!

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hello moderators, I would like to clarify regarding the plagiarism warning on my submission 374806988 for problem 2228E1.

I did not intentionally copy code from any participant during the contest. I solved the problem on my own and submitted my own implementation. If there are similarities with other submissions, they were unintentional and possibly due to common logic or implementation patterns for the problem.

I respect the contest rules and understand the seriousness of plagiarism concerns. I will also make sure to write more personalized implementations in future contests to avoid such situations. Thank you.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Subject: False Plagiarism Appeal — Round 1098 (Div. 2) — Handle: sudeepreddy7893

Dear Contest Coordinator,

My handle is sudeepreddy7893. My submissions for Codeforces Round 1098 (Div. 2) were skipped due to a plagiarism flag on problem 2228E1, matching with user MBBN. I would like to request a manual review of my case because I submitted my solution significantly earlier than the other user, proving that I did not copy from them.

Submission Details & Timestamps: My Submission ID: 374810486My Submission Time: 2026-05-16 18:41:31

MBBN's Submission ID: 374843969MBBN's Submission Time: 2026-05-16 19:30:02

As shown by the system records, my solution was written and officially submitted 48 minutes and 31 seconds before user MBBN made their submission. I did not collaborate with this user, nor did I share my code. Any structural similarity is either a consequence of the standard mathematical approach to this problem or a result of my code being accessed after my submission without my knowledge.

Explanation of my logic:To solve the queries efficiently, I first isolated the fixed sum and counted the number of open slots (free) containing -1. I used the standard stars-and-bars combinatorial formula C(R + free — 1, free — 1) to find the total valid configurations for the remaining sum R.

For the contribution of the prefixes, I applied the linearity of expectation. Since each empty slot expects an equal share of the remaining sum (R / free), the expected sum of a prefix containing A empty slots is simply ex = A * R / free. To compute the expected squared sum, I expanded the algebraic identity (fixedPref + freePref_sum)^2 into fixedPref^2 + 2 * fixedPref * E[freePref_sum] + E[freePref_sum^2], which I calculated using the combinatorics coefficients accumulated in the ex2 variable.

Given that the timeline clearly shows my submission came first, I kindly request that you restore my rating for this round. Thank you for your time and for maintaining the integrity of the platform.Best regards,sudeepreddy7893

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As a Chinese, I will give this an upvote

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

(Sorry to my poor English and my beginner code at first) Subject:​ Potential error in Editorial for Problem 2228B The 2228B's answer have some problem.When the distance of x1 and x2 == n / 2,the x2 should choose stay in place,and the x1 should stay too until the finally second,the k seconds x1 can choose move to make the distance -=1.Such as the test of n = 4,x1 = 1,x2 = 3,k = 2,if x2 move,the distance become smaller,it's wrong,so x2 should stay in place,and x1 didn't move in 1th second.But in 2th second,x2 also stay,x1 should move to 2 or 4,so the answer should be k — 1 + distance at first that is 2.But in the editorial,the answer is 3. I put my code here,it maybe have some wrongs: ~~~~~

include

include

include

using namespace std;

int dis(int n,int x,int y){ int dis = min(abs(x — y),abs(x + n — y)); dis = min(dis,abs(x — n — y)); return dis; }

signed main(void){ int LOOP; cin >> LOOP; while(LOOP --){ int n,x,y,k; cin >> n >> x >> y >> k; if(n <= 3){ cout << '1' << '\n'; continue; } if((dis(n,x,y) == n / 2) && k > 0){ k -= 1; } cout << k + dis(n,x,y) << '\n'; } return 0; } ~~~~~ Thanks!