Hello Codeforces!

CQXYM and I are glad to invite you to Codeforces Round #745 (Div. 1) and Codeforces Round #745 (Div. 2), which will be held on Sep/30/2021 13:15 (Moscow time). **Note the unusual time of the round.**

Each division will have **6 problems** and **2 hours** to solve them. All problems were written and prepared by CQXYM and me. The round will be rated for both divisions.

We would like to thank:

- Aleks5d for his excellent round coordination and many useful suggestions that greatly help with preparation.
- Monogon, voidmax, alexX512, ijxjdjd, wxhtzdy, makogon2907, 16204, Hemose, Hinai_Paulette, H4ckOm, 4qqqq, FBKdaisuki, kassutta, Mo2men and pkpawan for testing the round and providing useful feedback.
- MikeMirzayanov for great platforms Codeforces and Polygon.
- And you, for participating!

This is our first round, and great efforts have been put into preparing this round. Were you to kindly participate in this round, we would be very grateful and hope you will enjoy it.

Good luck!

**UPD:** Here are the scoring distributions:

Div. 1: $$$500$$$ — $$$1000$$$ — $$$1750$$$ — $$$2000$$$ — $$$3500$$$ — $$$3500$$$

Div. 2: $$$500$$$ — $$$1000$$$ — $$$1500$$$ — $$$1750$$$ — $$$2500$$$ — $$$2750$$$

And we would also like to thank Um_nik for testing the round.

**UPD2:** Editorial is out!

**UPD3:**

## Winners

Congratulations to the winners:

**Div1:**

**Div2:**

As a tester I would encourage you to participate in this round and assure you that the problems are interesting and good .

Update :- My review to testers

Thanks.

As a participant I will never trust your word again :D

As a Chinese participant I will never participate in Chinese rounds again :D

my face after reading problem A :

You should use a spoiler

So u really Trolled us!.

it is surely the worst contest I have taken part in

You were wrong

Here is my review I gave to problem setters . Name is blurred due to security reasons .review

Then you shouldn't have said all all these things (your comment)in the first place !

your review is good.

problem B has too many situations and what makes it worse is K (Diameter) might be negative.

and presets weren't sufficient to show wrongs during contest time (intended).

wtf???forces

Here it is!

Mathforces?

Mathforces!

It was FSTforces!

Sorry but I don't understand.

Just asking

I think he might be implying that cf contests prepared by Chinese authors tend to have more math problems. :)

totally agree after reading 1st problem.

20k+ users registered and only around 3500 submissions, weird...

They didnt have noticed the unusual time

You were so ******* right my guy. Damn

Hardforces!

Another Chinese round and friendly time for Chinese! Looking forward to great problems and having fun!

Sad, why isn't Monogon a VIP tester :(

I'm only moderately important this time.

What? 1-gon's comment didn't hit 100 upvotes in a day?? Impossible!)

This time is good for me.

Orz CQXYM!

Orz,2000 scores for a round!

Orz purple Hearth

Orz zqs!

Second Shortest announcement after Tourist's Round announcement Since I started using CF.

Bit manipulation problems?

I hope.

I don't have anything against Chinese rounds, but... really, morning on a weekday?

Probably people in different time zones exist.

That's why Saturdays exist.

ICPC World Finals I guess.

In China it is 6:05p.m. on the day before the National Day holiday. You can imagine the experience of participating a CF round after school :)

But (maybe?) most middle school students have to stay at school and study at night.

It often happens on weekdays. But if tomorrow is holiday, students can go back home in the afternoon.

I think that it's because the National Day holiday in China is coming.

However authors don't know 6 p.m. is even worse than 10 p.m. for many Chinese because most of schools end at 9 :(

However we must take the fact that ICPC World Final will be held today into consideration. Thus we choose 6 p.m. over 9 p.m.

Rare time....but maybe just right for Chinese contestants like me. I'm a little EXCITED. Hope all of us can enjoy it!

I finnish school 5 minutes before the round, can't join, but I wish those who read the greatest of luck.

I managed to convince the teacher to let me compete at school.

Big thanks for the time of the round from Asia! :)

Great, 3:05 AM.

i guess that's an i for an i for us having to participate from 10:30pm to almost 1am before...

interlude I think we need to update this blog to make this appear on top of the div.3 contest. Many people might not see it. Especially the unusual start time of the round. I didn't see this blog existed. Because the first post from the top was round 744. thanks for considering. :) good luck to the people who are participating.

lighthearted meme.

Hahahahhahahhahaa!!!Although no, it's not funny. You idiot.

You High on Weed . :) __ | | | | | | | | ( | | | | )

Hope you Understand my feeling.

That's not a good idea to play jokes like this on the Internet. We can sure that there was something wrong with the education you get from your parents.

заткнись телочка.еще что-то скажешь про моих родителей, зубы выбью тебе, тварь.

Meanwhile meHahahahhahahhahaa!!!Although no, it's not funny. You idiot.

Hahahahhahahhahaa!!!Although no, it's not funny. You idiot.

Hahahahhahahhahaa!!!Although no, it's not funny. You idiot.

let me stop you guys :)

break XD;

Imagine having school online, and not offline

Me:Now that the contest is over, are you happy with your decision?

i guess yes as he got a very good rank in this one

I have a test in my class today that completely overlaps with the contest timings. Cant skip them even if I want to

:sobb:

Another great round!! Hope I can do better than before in it.

Hi there. Could the contest be at 18.35?

The round authors are Chinese; I assume starting at 22:35 is not comfortable to them.

Oh, I am sorry I didn't think that. Thanks.

Hoping to become Pupil after this round...Best of Luck everyone!!

you did it! Congrats :D

Thanks a lot!!!!

As a Chinese,I usually leave school at 6:30 PM,so I cannot enjoy this round :(

Leave school, but don't leave a contest. (Don't take it seriously.)

And now I think I am lucky :D.

i do remember that one of the past contest nearly at the same time as of this one and it went bad ...........

Can you somehow postpone the competition for 2 — 3 hours? I think it would be more convenient to write everything in the evening than in the afternoon. usually the competitions are held at 17:30 Moscow time and this is very convenient.

Is 1900-2100 no longer in Div 2?

People rated <2100 can participate in div2, when it is div2Only round(so no parallel div1), but when there is a parallel div1 round, 1900+ have to participate there. It has been like this for a long time

Oh! I see

A way to increase contribution from 0 to 100:

0-20: leave stupid comments

20-40: write a blog on how to increase contribution from 0 to 20

40-60: write a blog on how to increase contribution from 20 to 40

60-80: write a blog on how to increase contribution from 40 to 60

80-100: write a blog on how to increase contribution from 60 to 80

A way to increase contribution from 0 to 126:

0-126: leave stupid comments

that leads in either ways UP or DOWN (+126 || -126)

Big thanks for the friendly time of the round:)

Actually, 9 p.m. is better than 6 p.m. for Chinese students.

Starting My Codeforces Journey From your round...

Hope to have my first giving round and your first making round great!

Thank you

My first div2 round here. Hopefully it doesnt go downhill. fingers crossed. I like this time slot :)

This ages very well

All the best to all the participants. :))

From contest authors and testers, I'm waiting really good contest!

Greeting all chinese people!Idk what's up with everyone, so retracting it for the better!

I think the content you posted is not appropriate, because we all know that the Great Firewall in Mainland China blocks almost all "user-generated content" websites, and codeforces as a "user-generated content website" is not blocked by it because There is very little political content on codeforces. If you post more content in this area, the result is likely to be that codeforces is blocked by the Great Firewall of China. As a result, it will cause great inconvenience to users in mainland China. They need to cross the Great Firewall to access codeforces.

Good.

However, according to some netizens in the QQ group

Universal OJ Users, almost everyone in China mainland who use Codeforces can across the Great FirewallBut anyway, I don't think any political content posted on codeforces is appropirate because codeforces is a website for people who love programming. I think whether it will make codeforces blocked or not it's not good to post content which is not about algorithms on codeforces

Although I heard some netizens say, and I also think whether Codeforces is blocked or not doesn't matter to many codeforces users, I think after all using websites not blocked is more convenient.

Lol, this is pretty good, don't know why it's being downvoted

can anyone tell me what is the process of penalty in DIV 2 round

Technically, there are no 'penalties' on time count. But yes, you get less points if you solve a problem after incorrect attempts.

Each problem is assigned points (e.g., Problem A in this round is 500), the faster you solve a problem, the more points you get. The amount of points you can achieve gradually decreases over time.

Problem A points deteriorates at a rate of 2 points per minute (you get 498 points if you solve after 1 minute, 496 points if you solve after 2 minutes, 494 points if you solve after 3 minutes and so on)

Plus, every incorrect attempt costs you 50 points.

Now let's see, if you solve that problem A after 10 minutes on your 2nd attempt, you get

`(500) - (10*2) for 10 minutes to solve - (50) for one incorrect attempt = 430.`

If you solve that problem A after 15 minutes on your 3rd attempt, you get

`(500) - (15*2) for 15 minutes to solve - (50*2) for two incorrect attempt = 370.`

Additionally, the minimum points you get on any problem is lower bounded by 30% of the max points on that particular problem. e.g., irrelevant of how many incorrect attempts or how much time, you will get a minimum of

`500 * 30% = 150`

for that problem A.Round delayed by 10 minutes

10 mins delay for my first contest...Bad vibes

deleted...

Time added 10 minutes!

contest extended by 10 min!

does it change anything?

Why this sudden addition of ten minutes in starting the round??

may be due to some technical issues

To reach 20K+ participations maybe.

Hopefully the delay doesn't signify an unrated round.

now what to do with 10 min of my life??

Think about what to do with 10 min of life

Listening to your words is just like listening to your words lol

Listen to your words, so I heard your words

https://ibb.co/5BhP7cy

how many point i need to join to div 1 ???

1900 and above

1900

I hope it'll be the only problem of the contest.

Wish all the best!!!

P.S. The "problem" here doesn't mean the problems that we're going to solve in the contest.

This doesn't really matter, but why would you use "obsidian" instead of "black"?

Minecraft

Because author wanted to complicate the problem statement without any reason.

If you can't write a nice problemset for cf, just move the problemset to other websites.

Terrible contest.

edit: Chinese slang

?______?It means he hates the idea provider due to hard problems, but it may be Chinese slang that is very disruptive and not appropriate to show in public.

First time not being able to solve (or not wanting to implement such an ugly solution for) even the first problem. Might just be me, but I think this contest needed a lot more tuning.

Thought it was one of best contests I competed in, besides B and C out of order. Finally some actual implementation and more ideas than just greedy/math with one for loop required...

If you can't solve a 30 line solution due to implementation I'm not sure you should be in div1. I've long said there is severe lack of implementation skill for most low div1 users and below.

Hardforces (: (at least for me )

Coding is very hard

div.1 too hard for me :(

Why would you write statement like this:

"and the diameter of the graph must be less than $$$k-1$$$?"

Couldn't you write "diameter of the graph must be less than $$$k$$$"?

Or even better, "diameter of the graph must be less than or equal to $$$k$$$?

For real, my code was so messed up I had to rewrite because I got confused in the middle.

I'm sorry but i am happy because today it's not only me who can't solve a single problem.

How to unregister?

Not my cup of tea...

Damn bro you didn't have to kill us with those problem statements!

Man!! explain me the problems. Cant understand anything from the statements

its my 2nd chinese round and i find it harder the usual div2 coz i can solve avg 2 problem but in this round i can't do even A. Chinese loves maths too much ≧ ﹏ ≦

only 3.7k submissions to problem A, btw WAonpretest2forces :(

At least I'm not alone, here we are :')Getting demoralized when not able to solve any problem.

then coming to comments-->turns out to be a natural therapy

Not even able to solve one quest, very tough round.

but atleast doing no submission won't affect my rating ^-^

I thought if you presented, no matter have you submit or no, It will affect your rating?

The wording of some of the problems are hard to understand :(

Bruh, I don't even feel like trying C cause pretty sure it's beyond my capabilities.

Spoiler`**GUESSFORCES**`

In the last 12 rounds held over the past 3-4 months, this is the only round where I had to spend ~10 minutes on both A and B just to be able to interpret properly what the question wants to say, never mind attempt to solve them. Statements were weirdly put, and maybe difficulty wasn't properly calibrated going by the meagre amount of submissions ~4k for div2 A even after an hour.

statement of div2 c is beyond my scope :')

one silly mistake costed 4 penalties on problem B :(

Same :(

Thanks a lot for clarifying this, before the round I was worried that my solution might also be tested on a negative number of test cases.

I am even not able to solve B this time, my brain exploded thinking of it :(

I am not even able to solve A :/

A flaw in the rating system exposed brutally by this round: in div 1, those who do manage to solve A, but do so late and/or with penalty attempts, will see their rating fall significantly, while those who bail out completely on solving A will see no change to their rating.

that's why A should always be comparatively easy in both divisions, can you imagine less than 6k participation in div2 :(

100% agree

Me on this contest be like:Click this

Damn, That's the hardest A and C I've ever seen

For me B Totaly was pain in ass!

HardForces :(

UPD: Sad, Got FST on Div.2 B :(

Today I will get -101 rating change :(

It`s really good, but is so hard:(

20000 registers 6000 contestants hmmm makes sense

Didn't participate in a Div. 0 before, but today i did.

I Just guessed the solution for A after 1hr 20 mins of waste analysis and it worked :/ and then solved B under 30 mins , strange round

Damn, couldn't even solve A.This contest really was amazing!

Is O(N^3) the intended solution for Div1 A or are you expecting O(N^2)?

$$$O(N^3)$$$.

Amazing. I had an O(N^3) time with O(N^3) space initially which got MLE.

Optimized it to O(N^3) time with O(N^2) memory and still got TLE.

Tried optimizing it further and got WA.

What a waste of 2 hours for me.

I solved it O(N^3 * 16) it gave me TLE but i break when i find solution with value greater than 16 and passed the pretests

Atleast you were writing codes. I was just crying for 2 hrs T_T

Yes, my O(n^3) passed

I think O(n^3)

Are the CF div2 rounds are getting harder or me getting dumber?

You just happened to be in the wrong contest at the wrong time

I am trying again on CF after spending a long time on Leetcode and DSA style problems. I am thinking to quit. It feels like a waste of time now but I am interested too lol. I don't know. I can spend this time on learning other skills like more backend. Will maybe just try to solve some harder problems for my range in the next few days.

A contest with really high difficulty...

So is there anyone tell me how to solve Div.1A/Div.2C. I got WA on pretest 18 :(

You can discover the property that the answer will not be more than 16. and just do it in brute force. it will be O(n * m * 16 * 16). Hint : try to use the number larger than 16, maybe 17.

I found that but failed to have further a further thought. Could you please tell me what the (16 * 16) is?

You are just checking min answer for the 5x4 matrix. But there may be test cases like 8x8 size 01111110 10000001 10000001 10000001 10000001 10000001 10000001 11111110 In this case, the answer is 0. But according to your approach, the answer will come to more than zero.

Any O(nlogn) solution for Div1C/Div2E? I only came up with sqrt decomposition XD

wasn't time limit a little too tight for sqrt decomp? :(

O(nsqrt(nlogn)) should work for n=100k.

Example: 1540D - Inverse Inversions

It has 5 sec limit. 1 sec limit kept me under the impression that nsqrt(n) is being punished here. anyways my fault :(

Not in this task, not with 1 second time limit, IMO. 1.5 seconds would probably be enough.

I passed system tests with $$$O(n\cdot \sqrt{n}\cdot \log{n})$$$.

I used a fenwick tree for big values of $$$x[i]+y[i]$$$ instead of just maintaining when to add or subtract something.

Weak systests :/ But I see that this solution was already hacked after contest. My solution with FT was a bit too slow too.

I can only come up with $$$O(n\sqrt{n})$$$ solution too.

The TL may be a bit tight for O(N sqrt(N))

In fact the constant of the solution is very small. I think even $$$O(n\sqrt{n}log_n)$$$ solution can also pass.

And O(n^5) can pass B with some optimization...

$$$O(n^5)$$$ is the expected complexity.

In fact you will find the constant is extreme small. A lot of state is useless.

That's really unexpected.. I thought author may have come up with something smarter to get $$$O(n^4)$$$ solution and set $$$n=100$$$ to cut $$$O(n^5)$$$ one..

In fact there do have a solution works in $$$O(n^3log^2n)$$$, but it's too difficult for D1B.

Well, that's surprising. Why didn't you set $$$n \leq 50$$$? It would be much easier to understand that the solution is fast enough and it's worth coding. Was it that important to fail $$$O(n^6)$$$ solution?

Um_nik played these games.

Sorry but I didn't come up with any $$$O(n^6)$$$ solution.

Then my question remains: why $$$n \leq 100$$$? Only to make some people not implement a correct solution?

"In fact the constant of the solution is very small." -interlude

I understand that the solution is fast enough. It would still be with $$$n \leq 50$$$. And this fact would be clear before implementing.

Just because the $$$O(n^5)$$$ solution can pass the task and it runs very fast. In fact you will find that the answer will be 0 if $$$m,k$$$ is larger than $$$\frac{n}{2}$$$.

Not always, my $$$O(n^5)$$$ solution got TL.

Are u serious? Only because of this, I didn't code the solution and thought for an O(n^4) solution for almost 1.5 hrs. And the constant isn't that small, recursion won't pass easily without optimizations (returning wherever you can).

However my O(N sqrt(N)) solution didn't pass.

I failed on both BC for TL

I think your solution for C is slow because of "cin and cout" .

I'm sorry but as a matter of fact,coder's submission has got another TL after replace cin/cout with faster IO streams. Isn't it obvious that this failure it due to implementing or Time Limit but not IO ways?

You are right..my bad

O(nsqrt(n)), you can operate trains whose x+y>=sqrt(n) and whose x+y<sqrt(n) in different way.

Perfect! Problems are challengable and of benifits. especially C, it`s great on both Thinking and Realization. All in all, great round.

Ooh man! one of the toughest A in div 2!!!

maybe you can just look at sample test cases to find the pattern without thinking much or proving anything . At least that's what I did XD

I figured it out with PnC but still I would say it shouldn't have had been an A problem, maybe B or B1 if possible!

The hardest ever

So difficult.

UPD : also fstforces.

Why is the diameter of the graph given as <=k-1, why not <=k ?

It's < k-1, My guess is just to add more confusion.

it's like let's make the contest very hard and confusing for the people who decided to participate at 3 AM as they already have a brain fog at this time :D

Am I the only one who has a bad feeling about system tests?

Well at least the judge queue will be short lol

Please, if you will write a round again in the future think about the quality of statements twice before. Some things were not very clear, like in div2 B where you should have specified strictly less, as you did while the round was going. Also, talking about B, it wouldn't be a bad idea to also write in bold important words, not just numbers and variables(here I'm talking about the word CONNECTED); you can see in other past problems that this is sometimes done, especially for important conditions like the connectivity one in B(for example for saying that all the numbers in an array need to be different). One last thing about this problem would be the limits for k, like were those special cases of k <= 1 really that important to be placed in the tests, ore are they even in the tests?

I am really confused why the diameter of the graph must be strictly less than k−1. other than k, it causes unnecessary confusion.

hardforce

don't worry, system_fail_forces also coming soon.

Couldnt solve anything. PS: Writing bruteforce and searching on OEIS is not "solving".

I feel like today's contest is suitable for Div 1.5 and Div 0.5

The round had nice problems (I read only div1A-C tho), though ridiculously hard. Could've easily been split into two separate div1 rounds with some easier, filler problems. I want to express my deepest sympathy to all div2 participants, who had those super tough problems given as C-E. Div1A should've been div2E IMO. To the authors, you did very good job with inventing interesting problems. Only that you underestimated their hardness and the overall contest turned out too hard.

That is the job of coordinators and testers but I don't know how can they all agree to serve all these problems together.

Some solutions for Div2 B will fail for this test: n = 1, m = 0, k = 1

is it NO ?

Yeah, some solutions didn't consider that the given diameter could be negative as well.

In first sample he told u diameter of the graph is zero, its obv. not strictly less than 0

Although I honestly don't see why the authors would want to make k start from 0 and not 1.

I felt,The definition of diameter is valid only when there are atleast 2 vertices. Is this assumption wrong?

Yes. The Answer will be NO

YES

Honestly how to iterate on this map in c++ for Div1 C ? map[(xi + yi)][day % (xi + yi)][xi].push_back({st_j, end_j}) Plus is it really the solution ?

Just use map.insert.

The solution is about O(n sqrt m)

Maybe the pretest is too weak?

system testing is super fast today!

Despite so many testers spanning across different ratings, a pretty unbalanced round.

Saw a pattern in the ans of A for n = 2 , half of the total-permutations and it actually worked for larger n

You could bold "connected" in B :/

k = 0 on problem B. Damn you guys got me!!!

Awesome difficulty Forces+FST Forces = Codeforces Round #745

system testing gotta go fast

Did someone mistakenly swap B and C?

Before the contest I thought B is easier but it turns out that I was wrong.

Who actually proved their solutions for A lol

lolhaha lmao . rofl . so funny .Not me lol

I thought of something like, if a permutation is valid, it's reverse is always invalid. So half would be valid and half invalid

Proof by symmetry is valid, and very simple.

I think you can make a one-to-one mapping from valid permutations to invalid ones; let's say you want to count permutations which have exactly $$$n$$$ indices such that $$$p[i]<p[i+1]$$$; it's not hard to show that by negating all numbers and then adding $$$2n$$$ to all of them, you are going to have a permutation with exactly $$$n$$$ indices such that $$$p[i]>p[i+1]$$$ (note that we don't have any repeated numbers, so this condition is the exact opposite of the one we consider valid.) Let's assume $$$\Pi(i)$$$ is the count of all permutations that have $$$i$$$ consecutive increasing pairs, and $$$\neg\Pi(i)$$$ the same for decreasing pairs; we know a pair is either increasing or decreasing; so we have: $$$\Pi(i)=\neg\Pi(2n-1-i)$$$; so we have: $$$\neg\Pi(i)=\Pi(2n-1-i)$$$; therefore, we have $$$\sum_{i=0}^{n-1}\Pi(i)=\sum_{i=n}^{2n-i}\Pi(i)$$$; I think by now you can see why $$$\frac{n!}{2}$$$ works in this problem.

What is test 4 for problem Div2B ?

I'm crying

I came up with a (n^2)m solution for Div1 A but it gave TLE. Is there a more efficient solution?

I also have this exact complexity and it passed. I used only vectors and pairs, maybe you used some more complex data structures?

Hmm. Seems like the constraints were tight. I see many solutions giving TLE in the system test.

Agreed, If the intended solution was O(n*n*m) it's just sad.

yep. FST for $$$O(n^2 m)$$$

130355128

update: constant optimization (using tuple instead of vector) passed with 139ms.

130386010

But it actually feels good to see a tough round now and then.

How to solve Problem C ?

hardforces + clumsyforces + (1.5 + 0.5 ) forces +system test fail forces + ....

so, bad round. lol

It is so reassuring to see that the problems were hard for everyone! Nevertheless, they were also really engaging.

important rule : don't join chinese contest LOL

FSTForces :(

shitty contest

I think the pretest in Div 2 B could have been a little better. Other than that, contest had really interesting problems, except C. I didn't like C, as the only solution that I thought of was implementation heavy, so I simply skipped it and moved ahead. E was good. Just missed the window for submission.

Annoucement-cum-Hardforces

everything in this contest was bad. even the problems.

Is it possible to solve Div1B faster than $$$O(n^5)$$$?

With 2D FFT we can solve it in $$$O(n^3log^2n)$$$.

I wondered if it's possible during the round. Nice :|

How? Don't you need division for that?

let dp[ k ][ i ][ j ] denote number of sequences of length i that have exactly j elements with k maximums (e.g. as in the number of maximums in the process defined in statement, e.g. the variable m). Then dp[ k ][ i ][ j ] is the sum over all i1 , i2, j1 , j2 , such that i1 + i2 == i-1 , j1 + j2 == j of ((i-1 choose i1) * dp[k-1][i1][j1] ) * dp[k-1][i2][j2]. This thing can be done with 2d FFT. E.g. we are fixing the position of the maximum element.

Edit: right, the modulo isnt guaranteed to be prime, not too sure.

No, its wrong.

1) it should be i1+i2=i-1, though that's pretty easy to handle

2) you forgot an (i-1 choose i1) factor, which requires dividing by i! before the convolution.

ohh right

I am not too sure i understand part 2). Do you mean calculation of (i-1 choose i1) mod p needs division ? If so, we can pre calculate that with pascal's triangle equality.

Edit : I see, makes sense.

No; you can divide by i! before convolution so you just do m convolutions of size nk; unless I'm missing something, directly calculating (i-1 choose i1) requires you to do mn^2 convolutions of size k, which is slower than the complexity interlude mentioned.

How to solve A ?? Intution ??

just apply bruteforce and and think what will be the answer when n =3,4,5

Most people just deduced it from the given sample cases

why ?? i need intution not just the plain answer :_:

You can find this rule by directly calculating the result when $$$n=3,4,5$$$

It's in fact $$$\frac{(2n)!}{2}$$$. For any permutation with $$$k(k>=n)$$$ such $$$i$$$, you can reverse the permutation and get another unique one with $$$2n-1-k(2n-1-k<n)$$$ such $$$i$$$. So answer should be half of number of permutations.

the answer is (2*n)!/2, because each permutation whose the number of pi < pi+1 is no less than n corresponds to another permutation whose the number of pi < pi+1 is less than n after you reverse this permutation

its simply a combinatrics problem ans : (2*n-1)!*(n) approach: for n there will be 2*n numbers and we can have no more than n positions with pi<pi+1 so we can place number n anywhere from pos (n+1) to 2*n then we can achieve the given condition

code... while(t--) {ll ans =1; ll n;cin>>n; fo(i,1,2*n) { ans=(ans*i)%MOD; } ans=(ans*n)%MOD; cout<<ans<<nline;

}

Tight ML in div2 C ;(

Sometimes I miss the old times when this assumption at least sometimes was incorrect.

The data of this task is actually difficult to make, and I can't come up with all the wrong solution too. Maybe we could communicate more about this task.

maroonrk what's incorrect in your code?

My solutions is like this:

The essential part of this problem is to make in-degrees of all vertices except the root no less than 2. For each vertex $$$i$$$, we know to which vertex $$$j$$$ we can span an edge. Valid $$$j$$$'s form a set of ranges if we order vertices by their distances from the root, and the number of ranges is at most the degree of the vertex $$$i$$$. My solution consumes O(number of ranges of the queried vertex) time, so it's a $$$O(NQ)$$$ time algorithm. However, it passed somehow.

Well, doesn't look like "we can't come up with all the wrong solution".

I didn't enjoy this round very much,not only because I got a negative delta.

(For div2) The problems are way harder than a typical Div2 round,Problem ABC are not very suitable for their place and Problem DEF are so hard that very few people can solve them during the 2h contest.

Also the statement is kinda hard to understand(maybe it's my fault for not reading the statement that carefully but).You have to read it mutiple times to find certain words like "connected" or figure out what the problem is asking.

Contests are used to seperate contestants into two parts:Those who are very good at Problem Solving and those who are not that good.They are NOT used to find out who are better at English reading and typing.

upd: obviously the pretests are weak too but I blame myself

one of the worst contests with worst pretests with hard problems

at all, you won the worst contest

true!

I agree with you.

how to solve c?

Every Time I think I am now good enough to become CM , My Rating Starts Falling Until it reaches Specialist Range

Sincerely, this round is not a good round. I have taken nearly 40 contests, and this contest is the first contest that I downvote.

1, the problem are so unbalanced, for div1, so many people are not able to solve A, and for div2, difficulty gap between B and C are too large, so as C and D.

2, div2 B is the worst problem I have ever met. It is so tricky, and description are soooooooo uncomfortable. What is "less than k-1" mean? Could you just write less than k" or even better "no greater than k". "n=1" is meaningless because we cannot pick two points from n=1, and "k=0 or k=1" is even more meaningless because, who want to discuss a graph with negative k?

3, div2 A are so unfriendly to newbies.

4, weak pretests

5, Except for the balance and description, a good contest should be educated. Even I cannot solve the problem during the contest and get negative delta, it doesn't matter. We can learn something after the contest, and improve our ways of thinking or coding skills.

But in this contest, I just want to say, what the hell of this ?? just a bunch of mind tricks or brain teaser? Can I learn something in the contest?

In all, getting up at 5:30 AM and take part in such contest is the most wasteful thing I have ever done.

systest is pretty weak too? I uphacked myself with a case with obvious 32-bit integer overflow...

130380959

I'm wondering if the pretest is too weak. I see many people got FST on 1C

In Div2 B, what is the expected answer for case: n = 1, m = 0 and any k. I guess according to definition of diameter given in the problem statement, diameter is not defined for n = 1 (we need at least 2 nodes to define diameter). I think the answer for this case is ambiguous and the problem should accept both "Yes" and "No" as the correct answers for the above-mentioned case.

totally argee

I think they made it quite clear the if n=1 the diameter is 0 by putting an example with n=1 and a note that says in this case the diameter is 0.

I agree but this thing should be mentioned in the problem statement itself, most people don't see the explanation of the sample test case.

Why condition in div2 B use less than k-1 instead of less than just k? It just creates some confusions.

something like

cin>>k--;what is test 61 in