Codeforces Round #455 for Div 2 competitors will be held on December 27 at 19:35 MSK. As usual, Div 1 competitors can join out of competition.
The round will be rated.
This round is based on tasks for summer contest for interns algO(1). If you have seen the problems from that contest before, please don't participate in the round. The problems were prepared by Maxim Kalinin (slycelote), Alexander Milanin (Milanin), Ibragim Ismailov (ibra) and me (Nickolas).
The competitors will be given six problems and two hours to solve them. The scoring distribution will be 500-1000-1500-1750-2000-2500.
We hope you'll like the problems. Good luck!
UPD: thanks to HellKitsune, vintage_Vlad_Makeev, 300iq, Arpa and Livace for testing the problems!
UPD: The contest is over. Editorial can be found here.
Congratulations to winners!
Div. 2:
Div. 1:
May I know how many people participated in summer contest for interns algO(1)?
We had 33 teams, each team had up to 3 people, so about 60 people.
33*3 , how this is going to be 60 ?
up to 3
... up to 3 people...
Obviously, not all teams had three members :-)
got it.
3 consecutive contests? I think this is a perfect end of year.
is it the boxing day of problem solving ?
"summer contest for interns algO(1).....". It seems to me some problems will be solvable in O(1).
Why always scoring distribution is announced later ?
She sets only contests like April Fools Contest 2017, Surprise Language Round #7 etc,
Seeing this one is already based on previous contest,
Get ready for Boxing Day.
a girl announces the round, hope it's a nice contest :D
Don't be sexist in 2018?
I don't see how this is sexist. He said he hoped it would be a nice contest. The fact that he mentioned a girl announcing a round might as well just be because he is surprised because of the low ratio of females in competitive programming.
What if I said "a guy announces the round, hope it's a nice contest :D?"
How many comments of yours would I see? (Hint: Zero)
I don't see how people can get along if every little thing is scrutinized as some type subversive sexism, when it really isn't.
If a guy had announced no one would have commented that in the first place.
Glad to see the scoring distribution one day before contest...:)
I_LOVE_EVERY_GIRL Nickolas
Three contests at the end of the year. A great gift by Codeforces! :)
The scoring distribution will be 500-1000-1500-1750-2000-2500.
thinking if I could solve 5 problems for the first time
Good luck
Sadly I can't make it :(
Still thanks ;)
Why don't you thank Mike?
good rating and easy problems will come to you
but only if you thank MikeMirzayanov for the platforms
It will be fun :)
are bhai bhai bhai
Mike say "Two consecutive contests without thanking me, and this one even not say 'hi codeforces'."
Again no one thanked to mike. ..it means :( Your text to link here...
Thanks Mike Mirzayanov for the platform and for awesome contests!!!
Dreaming of purple after these 3 contests!! Good luck everyone!
gl hf
Why does the tourist not attend?
Because he is busy traveling and contests for div 2 nine for div 1.
Did you assume he was not attending? He might even be attending on a fake account, kinda like how you are posting on a fake account.
because it's a div.2 contest...
The contest is hidden because no one thanked Mike, click here to view it.
Let's thank MikeMirzayanov on behalf of the codeforces community.
Can we enter the cobtest as a team ?
As you can see, there is no such button on
But after the end of the round, as usual, you will be able to start virtual participation as a team.
Can we hope for short problem statements?
I don't think so , they always have to make it complicated
there is something missing...
So happy adamant is finally not in the list of problemsetters! Just kidding though, the last two contests were pretty cool.
My New Year Resolution : I WILL WRITE CLEAN CODES
I forgot to register. Can someone register me for this contest (out of competition)?
The quote about extra registration:
Thanks Mike. It has been 10 mins, but dont see the extra registration icon.
slightly long queue right now!
Didn't like contest, statements were very hard to understand.
By the way, how to understand statement of B? I just wrote magical formula with samples and it got AC :P
Think of "layer" as in Photoshop.
Still don't get it. Looking picture for explanation, but it just don't give a sh*t.
Am I silly :(
Alternatively, you can think of "layer" as "set". A set of segments must contain pairwise disjoint segments. Find the minimum number of sets that contain all the segments.
Emm, I understood now. Thanks!
What was pretest 3 on problem C?
6 f s f s f s ANS : 5
Integer overflow I think
I think it is something like this
Answer: 6
how is the answer 6. i think it should be 2
Indentation of the first 6 statements (5 loops and first simple statement) is defined uniquely. The 7th statement can have any indent from 0 to 5 (be part of any loop's body or just follow the first loop).
How to solve D?
I think simulating with std set is fine.
I was thinkin about it but 10^6 constraint drove such thoughts away from me.
Well, time limit is 2s and it should pass if implemented correctly.
Hmm, maybe
you can use vector
How so? Thought it would TLE
Can you please explain the solution?
You can think of like maintaining two sets. One 'to_be_deleted' and other is 'candidate_for_deletion' (whose adjacent is to be deleted from first set). Now each item can be deleted from first set at most once and each item can be inserted into second set at most once. So, maintaining amortized complexity O(nlogn). Log(n) part for set insertion or find.
Simulate with std::list merging adjacent blocks, if of same color.
You can solve it in complexity O(n).
Group consecutive same elements and make one array of integers. Than all elements in new array will decrease in one operation by two except first one and last ( they will decrease for one). You can go over all groups and see minimum amount of operation to make one element of array lower than 0. Decrease all elements for that amount of operations ( first and last will decrease for that value and other will become smaller for 2 x amount of operations ). After this move remove all groups smaller than 1 and merge some groups if they have same letters.
At first view this looks as brute force, but actually this is O(n). In each iteration you will decrease each viewed element at least for one and total sum of that array will be exaxtly n.
What was the hack for problem A?
maybe ab bb types where answer should be ab and not abb.. so you have to check s1[i]<s2[0] and not less than equal to
Oh so that means that in my room, everyone was sharp and clever enough to avoid this mistake. :(
same :(
how to solve C?
dp[i][j] -> examining the ith prefix how many ways we can ident so that the ith statement is idented j times.
can you please explain a bit more?
Denote the ith statement with ai, we wish to calculate dp[i][j]. Then there are two cases. If ai - 1 = f then we just started an identation so dp[i][j] = dp[i - 1][j - 1]. Else (so we can delete some identations from the previous statement). To reduce time complexity we have to use suffix sums and use iterative dp to fit in memory.
thanks a lot :)
Or one can implement with recursive approach (who finds it easier) and pre call dp function in proper direction to avoid stack growth.
how to solve D? greedy strategy or some smart simulation?!
Is using Dilworths theorem and then finding max antichain using DP overkill for B?
NO.
Another alternative: If you can't understand statement like me, just search samples in OEIS and try every pattern. Works after some WA.
Probably :) The series which I got(pretests passed) were, if n is even, the series is 1+2+3...n/2 + n/2 +...1 and if n is odd, 2*(1+2+3...n//2)+n//2+1
@rajat1603 that is the precise definition of overkill.
When will the editorials be published? And how to solve C? Seemed like something to do with catalan numbers.
Editorials are up at http://codeforces.net/blog/entry/56666
How to solve F?
Ideas for C?
I solved it using dp
how did you use dp?
please give the recursion formula.
My English isn't very good but i'll try
let dp[i][j] be number of ways if you use first i commands and end up at nesting level j
if a[i] == f
then just dp[i + 1][j + 1] += dp[i][j]
else
from dp[i][j] we can get to any state of dp[i + 1][0..j]
you can calculate this if you use auxiliary array of prefix sums
ans will be dp[n][0]
and if you are currently at i == n — 1 you just do dp[i + 1][0] += dp[i][j]
dp(i, j) = number of ways to indent the first i lines such that the last line has indentation j.
Runs in O(n^2)
it seems like dp, but i didn't implemented due to time..
Used dp with cumulative sum to avoid TLE
Is the solution for B this:
floor(((n+1) * (n+1)) / 4)
It passed the pretests but I don't know about systests.
it passed
I had idea for C. First every consecutive f and one s we call a block, for example fffs. So you find number of blocks and also size of every block, where size is number of f. Then dp[ i ] [ j ] = dp [ i + 1 ] [ j ] + dp[ i + 1 ] [ j + 1] + ... + dp[ i + 1 ] [ j + block_i_size ]. Anyone solved this way? If u didnt, u probably wont understand me :P
Div 2B Solution :P
Is it just me or is E easier than B, C and D?
i didin't know about C and D, but i'm sure that B is easier than E.
Don't know about B but it's definitely easier than C and D
Don't know about E but B is harder than F.
A<E<D<C<B<=worthy div1.A<F IMHO :D
disagree
don't know anything but everything was hard :P
Does anybody know some counter tests for my solution at C. I saw many people got WA at pretest 3. Why? My solution.Your text to link here...
Recursive solution for problem B
At first think of all the segments that have left point at 0. There are total N segments that have this property. We can match every one of this segment [0, x] with a segment [x, N] and draw it in one layer. Thus, we need total N layers to draw all segments that start with 0 or ends with N. All of the remaining segments are defined by the points between 1 and N-1.
So, we can write, f(N) = N + f(N-2) where, f(0) = 0, f(1) = 1
Is C solvable using top-down dp ?
You may see rajat1603's solution
Div2C
What makes this solution fail?!
33689625
Try this testcase:
5
f
f
f
s
s
Its answer should be = 4
Did anyone solve D by another method : making a right arrays which stores the logical next element and making a left array which stores the logical previous element in array and then performing logical deletion by changing the left and right array values. Eg. _ a a b b_ _ left[i] {-1 , 0 , 1 , 2} ........._ _ right[i]{ 1, 2, 3, 4}_ .................... after one operation , left[i] becomes {-1,X,X,0} and right[i] becomes {3,X,X,4} and so on (by proper implementation procedure taking case of indices etc) and then count total number of steps(again proper implementation required). If anyone solved like this , please provide your code .
I was solving in similar fashion but I got TLE Here is the link
Isn't system testing too slow?
Good fight between problem D and E today
B had 102 test cases!!
It's a fantastic round :)
Winner here Congrats
Thanks :D
Will the user ratings change according to this contest? If yes, when?
shit contest made me gren
shit happens!
D and E were easier than C lol
E was easier than C and D, but D was harder than C, idea is very tedious in my opinion
D is pretty strightforward solution from early lessons of data structures (linked list, nostalgia). But in C you need to think a bit.
it was really a great round with really great problems and a fast editorial thank you for your efforts
Always have some submit Fail System Test make me a little bit annoyed,whatever that's the charm of codeforces i think :)
What???
how to solve division 2 C problem?