Hello Codeforces!
I invite all of you to participate in regular Codeforces round #309 that will take place on 24 June, 19:30 MSK.
Some of you may know me as lg5293 on Topcoder (you can see some of my past problems here), but this is my first time ever writing a Codeforces round. I've designed all the problems myself and I hope you enjoy them.
I want to thank ctunoku for helping me come up with stories for the problems, Zlobober for his immense help with preparation for this round, winger for testing the problems, Delinur for translating statements, and of course MikeMirzayanov for the superb Codeforces and Polygon systems.
I hope to see you all at the round. Good luck and have fun! :)
UPD: Scoring will be dynamic. Problems will be arranged by what I think is increasing difficulty.
UPD: Editorial is here. Congratulations to the top 5:
Div 1:
Div2:
I know you as a guy who writes huge answers explaining people who don't get the solutions :D . Huge editorials incoming
Thanks :) I'll try to live up to your expectations.
A month without div1 and 2 separated contest!
Last div1 and 2 contest was held on May/26/2015 Codeforces Round 305 (Div. 1) Codeforces Round 305 (Div. 2)... I wish we can enjoy your problem set.
Month without div1 and div2 separated contest — and now we'll have 2 such contests in 3 days :)
Really... I agree with you. I have been waiting this contests... good luck all of participants....
Nice, your problems are usually interesting. Too bad the round is at such a bad time for us in the Americas. I'd really wish there would be more rounds on weekends or just more variety in the contest times to benefit all time zones...
This might be a weird question, but for the last round you wrote for topcoder, div 2 1000 points, is there a proof of the pattern, or must one simply notice it? Thanks.
misof describes it in this comment. The key idea to note is to count the same thing, but in a different way.
i hope less no of unrated people in div2 since there is a div1 contest this time
Like you ?!
Finally, Div.1 come!
Congratulations)
eagrly waiting for div 2 intresting problems.. :)
Look at your TopCoder problems, I see a lot of maths, geometry, but few graph. Will this contest have almost maths and geometry?
I'm hoping for some data structures ... :P
Would be great if problems are of different types, imho :)
i study math olympiad. and i do programming for fun. i hope this contest have many math problems.
Then it would be a math contest, not a programming contest :(
Let's hope not...
I want data structures, sqrt-decomposition, trees, graph theory in general, etc..
Your taste is like mine :)))
How about a good dynamic programming problem?
Please make the problem statements clear and concise . I particularly don't like problems which are hard to understand . :D .
My first Div1 :D
i didn't participate in tc for almost 5 month
The first semester and the final exam just ended today...! I'm so happy to take CF at home, not dorm.
good round but bad time :(
Not so bad time...
really bad time!
because of final exams
If you want to participate, exams can not prevent ;)
I wish good luck to all students in the final exams successfully submit.:)
Yes, luck may help some of us :) Thnx)
Just a pic about my CF contest style:
Hope that contest will not as hard as contests of allllekssssa and PrinceOfPersia.
the blog post doesn't say anything about hacks :D
I think this contest have At least one Geometric problem
You hope...
Ooo I love geometric problems))
I belong to the first...
I don't know Russian but I guess this is the joke about binary system, isn't it? please translate for us
There is 10 types of humans in the world. Those who understand binary code and those who doesn't
So my guess was correct :D
how about this one:
There are 10 types of humans in the world: those who know binary system , those who doesn't and those who didn't expect this joke to be about ternary system
There are 10 types of people in the world: those who understand hexadecimal, and F the rest.
To people who click minus for this picture, you are very stupid! Yes, I'm waiting for minuses for this comment too...
Hope I become Expert in this round
Good luck)
yeah~The contest FINALLY comes,I have been wait for so long ....
I liked the problems of your topcoder SRM 652. I hoped it would be rated.
Izi problem, izi life
Difference?. nezametdinov's comment was +9 1 minutes ago.
i think you don't have another words, am i right? you always write the same.....
Such comments don't make your life "izi"!
Scoring? . . .
Dynamic ):
what does this mean ?
It means that the maximum scoring for a problem will depend on the total number of participants who send an AC solution i.e. the more people who solve a problem, the less that problem will value.
thanks !
beijing-----》00:30,shi fen dan teng!!(Very egg pain!!)
Since last job change, my rating was down down down. Hope this round would add some points. 00:30 for chinese player is too later in night.
Never mind :(
Codeforces is temporary unavailable ... :(
There was a lot of "website was not available" stuff... did anyone else experience this?
I couldn't open any problem for the first 5 min... :\
You will get extra 10 mins
but people have already submitted before i was able to open a question
will this be an unrated round ?
Why do you block recent actions page, the most useful page here, during the rounds?
Guys, sorry about failure on start. The reason is quite funny. Because of huge number of participants I blocked some pages to reduce system load. I don't know why, but this time I've blocked user profile page. But our internal monitorings have rule like
So monitoring systems decided that Codeforces servers were down and restarted them just before the round. And they were restarting Codeforces serveres again and again... until I unblocked user profile page.
Sorry participants, sorry Lewin :(
It's alright! Thanks so much for your work and contributions!
IMHO, Codeforces should consider the option to limit the number of participants to reduce system load (like TopCoder).
So this means if tourist is no longer red, Codeforces servers will lock down in shock?
Exactly. And not only Codeforces servers but me too.
or when tourist decided to change his handle to something else...?
No, because now codeforces redirects links with old usernames to their actual profiles.
REALLY? So many math problem in div 1 and 2. I honestly think that this round is pretty bad as almost all problems are only rely on math which are hard imo. I am not good at math and i feel very desperate. I hope next time will have a normal programming contest instead of math contest.
You should be aware of that possibility by looking at the previous writer's TopCoder problems.
Feeling like back in Permutation and Combination classes :(
feeling like imo paper
The clarification in problem B changes completely its meaning. I submit a solution to this problem for the wrong meaning, of course, getting WA. Changing it to the new problem required a lot of more code, so i'll pass ;(
No it doesn't, the problem statement is perfectly clear:
You start out with a bunch of cycles. Then you shift each cycle until it has its largest element first (it doesn't state that you are allowed to alter the cycles meaning so you can only shift). Then you sort the cycles with respect to each cycles first element (this can't be taken as sorting the elements in each cycle since the elements doesn't have a first element to sort by). This way we get a unique representation of each permutation.
There is no other way to read it.
Div1A felt harder than Div1B :(
All you had to do was scan a number and print 25*n+1. Easiest problem I have ever solved.
That's Div2A, he is talking about Div2C.
Nice problems, looking forward to your next round ;)
Lots of fun Math in this contest!
And not a single hack was given today.... :P
I was a single hacker in div2 today :D
great job.
I wish I read the announcement...
why is problemset still blocked ? i am waiting to submit a code from 2 hours and still cant submit
Lightoj 1226
Fix the link
Today's
Div1A/Div2C
is same as this problem ofLightOJ
!! AsLightOJ
requires login, you could see it here !!I'm sorry for the collision. Hopefully you found the other problems enjoyable.
The other problems blown upon our head. That means the domain of those problems were
Out of Range
of most of us!! However, Thanks a lot!Before resubmitting one should read the whole input restriction again. In Div1 A/Div2 C, I check that no of ball should be less than 1000 but forget to read that sum of them will be less than <= 1000 lost many points due to that.
I wish the contest could be extended by 2 more minutes....drat! I finally coded C and time up!
And it would've been Accepted had I been 2 minutes faster :******(
UPD. Nevermind, I got my mistake.
can someone kindly tell me what is wrong with my code?
I am basically doing search over number of possible splits of set of indexes. Number of ways to split n-element set on k subsets is Cn - 1n - k. Thus, of all possible splittings is . (F[n] in my code.)
So, I am simply doing search on my code according to the following rule. Suppose we are at position i(1 based). If F[n - i] > = k, then we need to merge this element with the next one (i + 1). Subtract k from F[n-i] and check if we have to merge current element i with the i + 2. When we face with the element j with which we do not have to merge current i element, we simply write {j-1, j-2, ..., i} to output array and move to position j.
For some reason, this fails. Code seems to be fine. I think the problem is in my idea. Could someone kindly tell me why what I am doing is wrong?
Sorry, can't see your code yet
All subsets must have size 1 or 2. This is because the smallest element in a subset must point to the largest, because the largest must be listed first in the cycle. Which also means that the smallest element must be listed last in the cycle (so it points to the first).
Someone really likes combinatorics.
If you want to do well in competitive programming, combinatorics is must.
I know.
How did you know!?
I thought you like DP.
only 1 unrated in top 10 of div2 :o
not now :P
Couldn't make a challenge on time cause my test with a size of 1mb was suggested to be too large. It was really a big surprise.(
You could use a generator?
There were like 20 seconds before the end. I couldn't quickly understand what's the appropriate format. I've never used generators button before, so...(
It was fun solving the problems. A different contest from rest ones.
Look at this and tell me what is the difference between these two submissions???
http://mirror.codeforces.com/contest/554/submission/11741175
http://mirror.codeforces.com/contest/554/submission/11746517
It does not allow to view others solution so early so be patient :P
Thanks but both are exactly same except in one solution I have added
ios_base::sync_with_stdio
and in other one I have removed it. The one with ios_base get wrong answer on pretest one and I wasted exactly one hour to find solution for B (div2) and resubmitted again and it got accepted :( :( I need exactly 20 second to submit C :(ios_base::sync_with_stdio(false);
turns of synchronisation betweencin
andscanf
, which means you cannot use both at the same time anymore.you initialized the j variables in the second loop differently
how do you solve "**Kyoya and Colored Balls**" pls share ur ideas
dynamic programming + combinatorics.dp[i][j] numbers of ways to fit in the first i all the balls from 1-j(all means all c[1],c[2]...c[j])so that at the i-th position I put the last ball of color j.So from that I can say that the last ball of j-1 color can be between 1 and i-1(to respect the condition from problem text)and also I have some space left after coming from dp[x][j-1](x<i),where i can put my c[j]-1 balls(because the last ball of color j is already on ith pos,so the others need to be somewhere in the left spaces). Hope you understood,I let you calculate the final formula :) The main ideea is that you need to place the last ball of some color j on ith position,so you come from a dp[x][j-1](x<j) :)
Just do combinatorics, first place all balls of color 1, this can be done in one way. Then place all colors of color 2, one of them must be behind all of color 1 balls so it can be placed in one way. The rest of them has to be put between all of the previously put balls which is a standard combinatorics problem (becomes
choose(placed_balls, new_balls + placed_balls - 1)
). The order of the already placed balls doesn't matter so you just multiply together all of these values.See this submission:
http://mirror.codeforces.com/contest/553/submission/11739706
can you explain why this is not working for pretest 2: we have balls 1 2 3 4.
According to formula we take 1 first.
for next color C(1 + 1, 1) = 2
for next color C(1 + 2 + 2, 2) = 20
for next color C(1 + 2 + 3 + 3, 3) = 84
1 * 2 * 20 * 84 = 3360 and not 1680 as it should be
C(5,2) = 10
Answer for C is 2^(number_of_components — 1) if answer exists and 0 otherwise.
Can you prove this?
Well any connected component has an unique way of being filled with missing edges. So take two components and a vertex from each one. You have two options, to either make it love or hate, from then on the components are connected and filling the other edges is unique again. So to merge two components you have 2 options, hence the 2^(components-1) to merge them all.
I don't have a formal proof of it being unique, but it is pretty easy to see it if you work it out on paper
How did you check that answer exists? Because I think that my check is harder than expected.
To check if answer exists assume any two nodes joined by love edge need to be colored with same color and any two edges joined with hate edge need to be colored differently. If you are able to get a valid 2-coloring(doable by a single dfs much like we do for checking bipartiteness of graph) then that particular component is ok.
Oooohhhh.... I didn't think this way. Thanks
let's assume that edge 0 means love and 1 means hate (opposite of input)
now assignment to the edges of complete graph is valid if and only if you can assign to each node value 0 or 1 such that for every edge its value is equal to the XOR of its two nodes
so our problem now changes to assigning values to the nodes instead of edges
for each competent there's exactly zero or two ways to assigns values to the nodes (if you find one assignment then by flipping the values of all nodes of this competent you get the other valid assignment)
if there's a component with zero ways to assign values to its nodes then final answer is zero otherwise the answer if 2^(number of components) (because we are multiplying the ways of all components)
Div1 C or Div2 C ??
Div. 1 C
What was the idea for problem Love triangles.I was only able to deduce the relations that must hold for a successful match but finding ways seemed to be a distant dream.Anyone?
Div 2 problem C was awesome !
How to solve it? I did'n even understand the 2nd example answer, how do we get it?
You have to use multinomial theorem.Take out 1 sample of each colour and then arrange the rest in front of it.Start from color 1 and move behind and multiply the ways you can get it .
http://ideone.com/3FLh1G But I didn't submit it.
my approach is close to DP, suppose we already placed the colored balls 1 ..k-1, then
we must place one k-colored ball at the end of the sequence and we place the remaining
k-colored ball among the the 1..k-1 colored ball already placed , which is a classical
problem of combinatorics
then we iterate allover the colors and that gives the result
sorry for my poor english
First all the balls of colors from 1 to i should be put before the last ball of ith color. So let's say that dp[i] gives the no of ways of arranging balls till ith color. Balls of colors from 1 to i-1 are arranged in dp[i-1] ways. There are s[i-1] = (c[1]+c[2]+ .. c[i-1]) balls arranged till now. Also put a ball of ith color at the end. Now there are s[i-1]+1 gaps between the balls that must be filled with c[i]-1 balls. No of ways of doing this tmp = (n+r-1)C(r-1) where r = gaps = s[i-1]+1 and n = balls = c[i-1]-1. Now dp[i] = dp[i-1]*tmp. Answer is dp[k]. Here is the 11741519
Was the score of the problem B changed ? Cause I saw a sudden drop in my scores for problem B ? I think something is wrong here
The scoring was dynamic today..
This contest had Dynamic Scoring.
After this contest, it reminds me of an amazing word — aftermath!
I didn't find any only-math problem in div 2. they all could be solved non-matematically as well.
In div2, C(div1 A),D(div1 B),E(div1 C) can be solved by maths... C(div1 A) is Combination number. D(div1 B) is Fibonacci number. E(div1 C) is counting the number of bipartite graph. I have solved only these three problems... Therefore I think it is a maths round!
Combinatorics and DP go hand in hand, so I guess that's not entirely mathematical imo.
At first, I have not noticed that the sum of c[i] is not more than 1000... So I think the sum may be as large as one million... I gave up DP and choose factorial numbers to calculate the combination numbers.
Actually, a million would pass. http://ideone.com/3FLh1G
OH NOES FIBONACCI NUMBER SO ADVANCED AND COMPLICATED MATH!!
AND HOW IT IS POSSIBLE TO DERIVE THAT VERY HARD FORMULA THAT NUMBER OF THOSE GRAPHS WAS 2|connected components| - 1!?!?
SCREW YOU LEWIN FOR THAT AWFUL PROBLEMSET, WE WANT PROGAMMING NOT SOME DIFFERENTIAL EQUATIONS!
P.S. Sorry if that seems to rude, but that's funny :P. However at least you don't complain that this contest was very bad, because there were only math problem xD (like some guys are sometimes claiming about various contests). Frankly saying, whole competitive programming is math for me :P.
Exactly. There was no difficult formula or some required prior mathematical knowledge to solve a problem. It was all based on observations that you don't need to prove. Really don't understand why people complain that it was too mathy, it was just logical solutions based on observations, just because it's not some by-the-book algorithm doesn't mean it's not programming :)
As I already said once before — try Ad Infinitum contests at HackerRank and you'll realize that given contest is far from math :) Unless you are calling every single programming problem "math", because programming itself is math.
If somebody says that binomial coefficients, number of n-digit 0-1 strings or fibonacci numbers is advanced math — I have bad news for that person.
Swistakk said smart things in his message above :)
Hackerrank is a good place to train myself. However, it cost too much time for a Chinese to open the website.
no pun intended
But math is what you love most (:3」∠)
Extremely fast system testing phase!
For the less mathematically inclined (like myself) :-
Div-2 C / Div-1 A was solvable using DP as well.
can you explain??
My method involved (hint): What must be the color of the last ball in the lineup?
We can go for a DP solution, if we consider the colors in the decreasing order. State --> (colorToUseNext, bank).
After using the color for the first time (remember we are going backwards), we can add rest of the balls with the same color to our ball-bank (balls of which can be used anytime now).
Alternatively, we can use a ball from the ball-bank as well.
The overall idea is to construct the sequence in the reverse order, and filling the current position with either a ball from the "bank", or using a color for the first time (and adding rest of the colors to the bank, to be used later.)
Ouch, resubmission penalty with dynamic scoring really hurts.
you react as if pain was inflicted by physical touch !
Yes... For 250's problem, resubmission = 50 penalty = 50 minutes penalty...
As for 3000's problem, resubmission = 50 penalty = 4 minutes 10 seconds penalty...
Math is cool, Math is great, Math is really tricky thing.
i think problem D's time-limit has been set by a cruel person :| he just ruined my contest
What is the complexity of your solution? Mine runs in 170ms
Edit: My complexity is O( (n+m) log n )
There is a solution, which passes comfortably (probably can be optimized to O(n + m)).
In life we learn from our mistakes and in this contest i learned that "Every city will have at least one road adjacent to it." does not means the graph is connected :)
bad luck! The problems is the same, but you need see each component =(. 3 lines of code more, no?
Yes. Exactly 3 more lines of code
Ahhhh... 0,5 of wrong submission away from being on Petr's blog third time in a row! I need to do better in Friday contest :P
How to solve div.1 E? I think, I know the solution in case of acyclic graph, but adding some hacks for cycles makes this solution TL =(
I tried something like this:
Let dp[v][r] be a best expectation if we are in vertex v and have r units of time remaining. There is a straightforward way to compute it in O(mt2) by some easy formulas and to speed it up we need to observe that in those formulas there are some convolutions. That means that we can use multiplying polynomials to compute them. However there is a really big problem with, we can't use just one FFT, because we are adding coefficients one by one and we have to be able to update result of multiplication. That can be done and is a really nice (but not that easy) exercise which I will leave up to you (this adds logarithmic factor to complexity).
Do you know any other problems involving this semi-online FFT approach? I was REALLY amazed when I came up with this idea while solving this task.
Yes, this one: http://mirror.codeforces.com/contest/438/problem/E
Here's Egor's solution which uses that semi-online FFT http://mirror.codeforces.com/contest/438/submission/6774697 , he solved that using sqrt-decomposition (which results in complexity). But first time when I encountered it was just my head, someday I came up with such problem on my own and solved it exactly using that sqrt-decomposition, but after that contest tomasz.kociumaka told me how to do this in and I tried coding it today, but lacked time.
I've seen such approach on codechef.
I loved this contest! A lot of problems to think. No theoric problems =). These are the best competitive problems!
I really enjoy the contest, but i have 40 minutes to code problem D from i found the solution and I didn't solve. I need train to code faster the problems =/.
Thanks lewin!
so motivated girl coder... great job!
It's not sarcasm :D
It was very difficult to hack in this contest
When do we get ratings?
is this round unrated? UPD-> rated :)
UPD -> unrated!! New rating is removed!
I say, "I'm violet!" Codeforces says, "Shut up, you are blue forever"
UPD. I'm violet now :)
Blue-Zoned ? No CF isn't a bitch rated again PS i had same story xD :D
Isn't the statement for B wrong considering the intended solution? for example (3 1 2) is decomposed into the cycle (3 2 1) that reorders to (3 1 2) so it is good.
Why does it reorder to (3 1 2)? I think it stays (3 2 1)
some people like me thought that we should sort elements of each cycle in decreasing order in order to make first element is the biggest, but until the last moment I knew that we should make shift to the sequence of the cycle to make the first element is the biggest element
Actually I was one of those people and I thought the whole cycle is sorted in decreasing order, but still arrived to the same solution. Isn't the solution in both cases the same, or was I just lucky?
since I assumed that we should sort elements of each cycle in decreasing order I assumed that for example 3 1 2 5 4 is not one of the permutations that we should count because (3 1 2) is not sorted in decreasing order
But {3 1 2 5 4} indeed shouldn't be counted.
it turned out that I still don't understand the problem
If you sorted the whole cycle, you would count 3 2 1 5 4 for example, which you shouldn't.
No, you wouldn't. It changes: 3 2 1 5 4 -> (3 1)(2)(5 4) -> 3 1 2 5 4
Yep, indeed, the solution for both seems to be identical so the "confusing" statement ain't an excuse :P
Point taken. I guess this problem was easier if you were more familiar with cycle notation; I made a similar mistake during the round (I understood the statement correctly though). :/
Yes, the solution for both the cases was same.
reordering of (3 2 1) is (3 2 1) itself.
You cannot reorder cycle in that way, because links between elements of permutation are directed.
Maybe it's just unusual wording, but aren't "reorder the elements within cycle" and "cyclically shift the elements in cycle" different things?
Hmm, from that point of view they look different for me, agree with you.
However, there was a clarification about that (around 54 minute of the contest): "In order to get standard cyclic representation, you should write elements of each cycle in order of cycle starting from the largest element of the cycle (not just in decreasing order)."
Sorry for the confusion. I will remember this wording in the future. Also, another thing that I could have done was to make the standard cyclic representation in the statement not be in decreasing order.
If (3,1,2) is not considered a valid permutation, then problem statement is wrong. It only asks to reorder elements in a cycle such that largest should be at the beginning, so (3,1,2) upon reordering will stay the same. The clarification was not clear to me.If it meant that you have to sort the cycle in decreasing order , then of course (3,1,2) is invalid as it reorders to (3,2,1) which is different.
Thanks to the organizers of this round, problems was very interesting. I hope you will invite us to your new Codeforces rounds in future :)
Really glad to see top5 in Div2 without a single newly registered user :)
What's wrong? I became div1 and then rating changes are undone and am div2 again.
For some reason my rating increased by 77 and then went back down a few minutes ago to what it was before the contest. Is the contest unrated?
Same here, my rating changed and then came back. What happened?
.
Maybe they are just catching cheaters.
Yay it went up again! :D
Yes it did. However, I gained 38 rating points in the previous rating update. This time I gained one less rating point, although my rank went up by one :P
It seems like they caught one cheater :)
Had become Candidate Master for the first time. I thought it would last for at least 1 contest. :P I should have saved the screenshot.
You can save it now :P All rating changes have been rolled back. (for sometime I guess)
For me solving div2 D (div1 B) was completely random. Observing the complex problem statement I've implemented precalc which filters valid permutations out of all the permutations (with std::next_permutation) and then I've noticed the Fibonacci sequence :)
Where are the rating points gone ?!
they are back :)
Div 1- Ques B
In Testcase 5, the result for (10,57) is 2 1 3 4 5 6 7 8 10 9
When I generated the sequence using my cod, the following is the output. Where is it wrong?
(10,1) -> 1 2 3 4 5 6 7 8 9 10
(10,2) -> 1 2 3 4 5 6 7 8 10 9
(10,3) -> 1 2 3 4 5 6 7 9 8 10
(10,4) -> 1 2 3 4 5 6 7 10 9 8
(10,5) -> 1 2 3 4 5 6 8 7 9 10
(10,6) -> 1 2 3 4 5 6 8 7 10 9
(10,7) -> 1 2 3 4 5 6 9 8 7 10
(10,8) -> 1 2 3 4 5 6 10 9 8 7
(10,9) -> 1 2 3 4 5 7 6 8 9 10
(10,10) -> 1 2 3 4 5 7 6 8 10 9
(10,11) -> 1 2 3 4 5 7 6 9 8 10
(10,12) -> 1 2 3 4 5 7 6 10 9 8
(10,13) -> 1 2 3 4 5 8 7 6 9 10
(10,14) -> 1 2 3 4 5 8 7 6 10 9
(10,15) -> 1 2 3 4 5 9 8 7 6 10
(10,16) -> 1 2 3 4 5 10 9 8 7 6
(10,17) -> 1 2 3 4 6 5 7 8 9 10
(10,18) -> 1 2 3 4 6 5 7 8 10 9
(10,19) -> 1 2 3 4 6 5 7 9 8 10
(10,20) -> 1 2 3 4 6 5 7 10 9 8
(10,21) -> 1 2 3 4 6 5 8 7 9 10
(10,22) -> 1 2 3 4 6 5 8 7 10 9
(10,23) -> 1 2 3 4 6 5 9 8 7 10
(10,24) -> 1 2 3 4 6 5 10 9 8 7
(10,25) -> 1 2 3 4 7 6 5 8 9 10
(10,26) -> 1 2 3 4 7 6 5 8 10 9
(10,27) -> 1 2 3 4 7 6 5 9 8 10
(10,28) -> 1 2 3 4 7 6 5 10 9 8
(10,29) -> 1 2 3 4 8 7 6 5 9 10
(10,30) -> 1 2 3 4 8 7 6 5 10 9
(10,31) -> 1 2 3 4 9 8 7 6 5 10
(10,32) -> 1 2 3 4 10 9 8 7 6 5
(10,33) -> 1 2 3 5 4 6 7 8 9 10
(10,34) -> 1 2 3 5 4 6 7 8 10 9
(10,35) -> 1 2 3 5 4 6 7 9 8 10
(10,36) -> 1 2 3 5 4 6 7 10 9 8
(10,37) -> 1 2 3 5 4 6 8 7 9 10
(10,38) -> 1 2 3 5 4 6 8 7 10 9
(10,39) -> 1 2 3 5 4 6 9 8 7 10
(10,40) -> 1 2 3 5 4 6 10 9 8 7
(10,41) -> 1 2 3 5 4 7 6 8 9 10
(10,42) -> 1 2 3 5 4 7 6 8 10 9
(10,43) -> 1 2 3 5 4 7 6 9 8 10
(10,44) -> 1 2 3 5 4 7 6 10 9 8
(10,45) -> 1 2 3 5 4 8 7 6 9 10
(10,46) -> 1 2 3 5 4 8 7 6 10 9
(10,47) -> 1 2 3 5 4 9 8 7 6 10
(10,48) -> 1 2 3 5 4 10 9 8 7 6
(10,49) -> 1 2 3 6 5 4 7 8 9 10
(10,50) -> 1 2 3 6 5 4 7 8 10 9
(10,51) -> 1 2 3 6 5 4 7 9 8 10
(10,52) -> 1 2 3 6 5 4 7 10 9 8
(10,53) -> 1 2 3 6 5 4 8 7 9 10
(10,54) -> 1 2 3 6 5 4 8 7 10 9
(10,55) -> 1 2 3 6 5 4 9 8 7 10
(10,56) -> 1 2 3 6 5 4 10 9 8 7
(10,57) -> 1 2 3 7 6 5 4 8 9 10
(10,58) -> 1 2 3 7 6 5 4 8 10 9
(10,59) -> 1 2 3 7 6 5 4 9 8 10
(10,60) -> 1 2 3 7 6 5 4 10 9 8
(10,4) -> 1 2 3 4 5 6 7 10 9 8 is not valid
The cyclic sequence will be (1)(2)(3)(4)(5)(6)(7)(9)(10 8)
ok got it , thanks.
I read the ques wrongly.
Rating update (1699) :O ... i would have gotten this point if i would have entered the contest without 8 minutes temporary unavailable :'(
Either I am stupid or div 2 D is actually hard to understand. I still don't understand what the question wants me to do.
Very cool problemset, thank you :).
The problem set was awesome, loved to solve it :)