0
What if someone solved a problem after 1 minute of the server problem and one after 29 minutes ? Are they going to get the same score? 
0
Think about it this way. For your condition tu hold, the value n must within the last K positions. And you can choose the following values in ways, where is length of the suffix starting in value n. Then you have to multiply by the number of good permutations of size . That is, . This is exactly the same as choosing a cycle for element n of size at most K, and then multiplying by the number of good permutations for the remaining elements. I'm not sure if I understood what you mean by counter test. It's true that the permutation you show should be counted as good for the problem statement, but it does not comply with the condition you mentioned. 
0
That's right. but those could be very better. codeforces is a good and popular site as a result anyone have high expectations. I hope codeforces be better in the future like always! :) 
0
Wonderful explanation !! Thanks a lot :) 
+15

0
How many participants from this round will be chosen to the final? 
0
Thanks for this but i dont quite understand how the graph is being made. Can you please explain for this input
Thanks! :') Update: I've understood thanks! 
0
I wonder how many contestants solved this problem without OEIS. 
0
I have given up on the contest when there was more than an hour left and almost got to top 100. Suspicious. 
0
Thanks 
+12
although there where a lot of technical issues and despite that i spend more time reloading pages than the time i spend on reading problems, it was one of the greatest contests i ever participated in,thank you for your efforts it was totally worth it to participate even though it wasn't rated in the end. 
0
No..Because occurence of k is more than occurence of kas and kad. 
+10
In Div1C Counter Test K=3,

+24

7
To solve Div1 C, Div2 E Let's calculate two functions: dp[i] — How many [i] permutations exists, where last element is i and will return correct maximal value. dpsum[i] — How many [i] permutations exists, where element i is in one of the last k positions and algorithm returns correct maximal value. Then we can calculate these functions in linear time: To calculate dp[i] we simply append i to the end of all the [i1] permutations, where i  1 is located in one of the last k positions and algorithm will return correct maximum value. dp[i] = dpsum[i  1] To calculate dpsum[i] we must remove all permutations, where maximum value will be located outside the last k elements of permutation from dpsum[i  1]. Then append new element to the end of permutation, it must be less than previous maximum value. So multiplying by (i  1) we add this new element and increase all larger, equal permutation element values by one, so we get [i] permutations, where i is located in range [i  k + 1, i  1]. Lastly, we must append all permutations which have maximal value i in the last position of [i] permutation, we calculated it in dp[i]. Then we can calculate the number of all good permutations, where correct maximum value is returned by algorithm. Lets fix position i, where maximum value n will be located. Then first i element prefix of permutation must return correct maximal value and maximal element is in the last position of permutation formed by prefix, so we use dp[i]. We choose order of last n  i elements in (n  i)! ways. Suffix of last (n  i) elements forms a permutation. Then we must merge these two permutations together by merging all elements except maximal n together. This can be done in ways. Then the number of bad permutation is count of all [n] permutations minus good permutation count; answer = n!  good_perm_cnt 
0
Wut, noo, now I can't make round 446 :( 
Created or updated the text 
0
I misunderstood the statement and tried solving a slightly different problem On visiting a vertex the second time, any integer between 
+46
Rated round: Unrated round: 
0
You could have seen in the explanation for example 1 they give 1 > 1 > 2 as a possible solution. 
0
Actually I had to make a choice : 1) write a lot of true and bad things about the situation, 2) show anger and protest subtly. Is this that difficult to see that yourself :) 
+2
Or you can just not visit the site, instead of unregistering the account altogether. As for receiving mails regarding contest announcements, you can just unsubscribe them. Is this idea that difficult to come up with? 
8
Let's find dp[n]. Obviously, you can place the number n only in the last k spots, otherwise you would have more then k numbers smaller then n after n. Lets say you place number n at position i (so you have i numbers, then n, then ni1 numbers) (nk<=i<=n1). The first i numbers also have to respect the condition (of no k decreasing consecutive numbers), so there are dp[i] ways of arranging them. Also, there are C(n1,i) number of ways of choosing the first i numbers out of the n1 other numbers. We can arrange the last ni1 numbers in any way, since n will be bigger then all of them, so there are (ni1)! ways. Final formula: dp[n]=sum(dp[i]*C(n1,i)*(ni1)!)=sum(dp[i]*(n1)!/i!)=(n1)!*sum(dp[i]/i!), where i is from nk to n1 
0
suppose if the set is ab, ba then i can construct the string abba, in which all the substrings in the set occurs once and all occus exactly same amount of time. Also if it is kas and kad then kaskad is a good string right ? 
+88
My story on problem A:

11
i got a notif that its undated :( Please make it undated but not unrated ;_; On a more serious note, how to unregister my account? I don't wanna come here anymore... 
10
it hurts when you expect a positive rating and the round ends being unrated. 
0
Actually it was a good contest except the bad gateway problem. Problem statements very fairly clear and some hacks are always expected in div2A. 
0
Can you please explain this dp? I struggled for the whole contest to find this. 
0
I think your problem might also have overlap issues. Consider the step when n = 10 and k = 1. For the permutation {1,2,4,3,5,6,10,7,8,9} and a=3 your solution would consider false_max=5, whereas the false_max should've clearly been 4. 
0
Indeed, I forgot to mention that as well. 
0
Yeah, you also need to make sure there are no cycles; as an example, the answer for 2 ab ba is NO and the answer for 1 aa is also NO. 
+40
Codeforces became one of the most searched today websites on websitedown.info! 
0
I will be expert if this is rated. pls........ 
+3
Construct a directed forest as follows. Nodes are letters. If one letter right after another in one of the words, then there is an edge from the first letter to the second one. There must be as most one outgoing edge and one ingoing edge on every node, otherwise answer is NO. Tricky thing: some words have only one letter in it, one should care about that. Once you have a valid forest, just print the letters in the order given by the forest. 
0
omg. Thanks. sad ;/ 
+1
Here's how I did it (With the same assumptions as you did):  Put in all the strings in a set S.  If any string has a repeating character, print NO(since this character will have more counts than the entire string).  For every character c in the alphabet, do the following: Make a set of all strings that contain this letter, say T, and while the size of this set is larger than 1, pick two strings from this set, merge them, and insert result in the set S. (Remove the original strings from S and T) If it is not possible to merge any two strings, then print NO (because the final answer has any character appearing atmost once.) To merge any two strings, check the prefix and suffix from c's position in the two strings.  Finally, you have only disjoint strings remaining in the set S. Concatenate them lexicographically and do a final check for repeating characters. 
0
Construct from strings graph symb  > nextsymb. This graph must be: 1) uncycled; So from that graph you must iterate over vertexes that have no one edge points to them and create answer. Example: ab kas 
0
Better luck next time! 
0
Try: 2 ab ba 
0
How to solve DIV2 D ? 
0
sm1 hold me, captain obvious is striking so hard 
0
I was wrong, i thought ans for 3 aa bb cc would be aabbcc. but the ans is no. 
+9
Hmm okay, provided that they ended up seeing this long comment and figure out my misunderstanding... :< Anyway, thanks, just for having a nice response ;) 
0

+1
How the initial strings look like? 
+3
Well, some will find it useful anyway 
+1
For example: n = 5, k = 1 You will count this permutation twice: 2 1 4 3 5 
0
I do not care if this contest is rated or unrated. I only wish discovery test case 4 for D. UPDATE: Got AC with this case. 
+8
no 
0
This idea was applied in csacademy round 37 
+8
Ouch... sorry then. Should I delete this for now? 
0
such garbage these last 2 contests were. hopefully this is going to be unrated 
0
Thanks for letting me know where I got my number wrong! 
0
Yep, I did both of them but they were'nt very useful :( 
+3
Well i couldn't solve Div 2 D but here are some of the things that i had thought of during the contest. If someone has solved with similar assumptions then please help in how to construct a solution from here.
Can anyone help me create a solution from here or if my assumptions are wrong then point em out please? Thanks :) 
0
With all due respect that is very nice but he asked about Div1 C 
+1
Let's run the system test. For one I'd like to know if I messed up on div. 2 ABCD. For another, I really wanna upload my updated version for problem F just to see if I did it correctly lol 
+7
CF server trying return

0
Says the person who trolled everyone on cf discord that it was rated. Evidence: https://snag.gy/c7Cj0g.jpg 
+1
Situation of the last two contests in Codeforces 
0
Some of us have problem with the round being rated. Because if the server wasn't down, we could have submitted our code early. But as CF was down for approximately half an hour, we got huge penalties :( which will brutally decrease our rating. If we could submit codes just in time, our rating would not be this massacre. So please make the round unrated. :( 
10
I would, but I don't precisely recall the exact contest. I could dig around the previous 100 contests, but that would be painful. I'll just leave my suggestion as is. 
0
There was a solution in my room which checked a[0]+a[4]+a[5]==a[2]+a[3]+a[1]. I hacked it using 1 6 7 9 10 11. Several other hacks are possible. 
+8

13
"temp *= mod_fac(a + k, mod);" its actually not (a+k)!, since in the first a numbers there must be no k consecutive decreasing values, otherwise you will stop at them and not reach the a+1th value. to calculate this number, let dp[i] be the number of ways to permute first i numbers such that no k are increasing. dp[i]=(dp[i1]/(i1)!+dp[i2]/(i2)!+...+dp[ik]/(ik)!)*(i1)! (i is from nk to n1) 
+43
New version: 
0
I wanna pass ABCD 
0
yep! you are right! 
+50
Let's run the system test, if i passed the D the round should be rated. 
0
I just realized that after posting my comment, too. I spent my last 10 minutes trying to Google about nCr % p, but some copypaste can't save me though... 
0
for who used sum/2 for checking ... 1 1 1 1 1 2 for sorting and then grouping (0,1,5) — (2,3,4) ... 0 1 3 4 7 7 
0
solution will be a forest of linear trees 
+3
is there is a solution if a character occurs twice in a string? 
0
I thought of the same thing (you're using the fact that X halves or stays the same at each step)? You can also do something like: "if (a[i] <= a[i + 1]) delete a[i + 1] and increase the coefficient of a[i] by 1" and you get a decreasing array, with some extra coefficients. Still not very useful though:( 
0
one guy in my room checked d+e+f == c+d+e. Hacked. 
0
implementation 
+10
Can you point which ones to me? 
9
Lagforces servers be like 
0
Well, they've done it for a few contests in the past and it seemed to meet most people's demands. 
+4
Hint : Will the result contain a character more than once ? 
0
How to solve Div2D (Div1B) ? It'd be nice to give hints before the complete solution. 
+3
What is the reason of this server break downs? Poor servers, DDOS or smth? Can anyone explain it? 
+6
All right, go rated 
0
Many people checked sum/2. It get WA when sum is odd. 
0
Oh wow what a coincidence, we posted the same wrong solution at the same time! 
8
In my opinion, greedy algorithm can be a fine approach. I used an array (I'll name it A): element with index i is used to store the index of the room which was last visited in minute i. (if this room is visited again in the future, the value of this element is changed back to 0). Then I did a linear check over all numbers in the notebook: Assume that the number written in minute i is x. If there was a room which was last visited in minute x, we could assume that that room is visited again in minute i (it's the easiest way to handle without adding new rooms). Assign A[x] to A[i], then assign 0 to A[x]. Otherwise, since no room was last visited (until minute i) in minute x, the man must have enter a new room. Increase the room count by 1, and assign the index of the new room to A[i]. Hope this will help. And sorry if my expressions could be complex though... 
0
nah, the rating inflation will be skyrocketing if that were the case. 
0
yeap, sorry =( 
0
In Russia we had this problem too. It was not because of terrible Internet but because of problems on codeforces 
+6
it was not bad really . problem were pretty clear and pretests were not too weak . i was busy coding div1 B for almost the whole contest so i didnt get that gateway error at all ! however hacking was almost impossible 
0
That's a good idea. emmm.... 
+3
Hacks for Div 2 a? 
+4
A 9gagger, I see you're a man of culture as well. 
+5
How do you solve problem E? I got WA on test case 15 with this formula so I want to know if the formula was wrong or if it was something in my code. 
0
My attempt on E (Div 2.): We will construct a permutation that has the following structure: Starting with
That is for one Here is the pseudocode:
I got Wrong answer on pretest 15. Is there anything wrong with my solution, or just that my implementation is so poor that it can't handle the mod part? 
+13
1) Brute force it 2) Search for the first two columns on OEIS 3) Find a pattern 4) ??? 5) Profit! 
16
I hope they consider making it rated for those with positive rating gains and unrated for those who lose rating (as they've done in the past). This could satisfy everyone? Edit: I don't understand why a reasonable suggestion is being downvoted. 
0
How to solve E? f(1, x) can be computed in O(log^{2}), I'm not sure it has anything to do with real solution, though. I tried some randomization stuff but couldn't pass pretests. 
16
I was unable to hack in the last 67 minutes, but still, let's not make the round unrated. Even the last rated round was unrated. Looks like, system issues are becoming rather common, so this way, who know when we'll have an actual rated round. Please don't make it unrated. 
Name 
