Hi!

Tomorrow, on March 24-th, 2018 at 15:35 UTC we will host the second round of VK Cup 2018 — a programming tournament for Russian-speaking youth. 450 teams that were the best in the first round and the first wild-card round will compete tomorrow. The top 100 teams will advance to the third round directly and get a tournament t-shirt, while the others will have one more chance in the second wild-card round.

For English-speaking community as well as for those who haven't advanced to the second round or haven't participated in VK Cup 2018, we will host parallel Codeforces round for both divisions, as usual. Feel free to take part!

**Please note that the tournament is for Russian-speaking people. If you don't speak Russian, you must not compete in the VK Cup round, register for the parallel round instead. Otherwise it is considered as a flagrant violation of rules and might be subject to disqualification and Codeforces ban. Please respect the organizers.**

VK Cup 2018 Round 2 and the round for the first division will have six problems each, the second division round will have five of them.

The authors of the problems are cyand1317, skywalkert, Claris and me. Also many thanks to fcspartakm, Tommyr7 for their help in preparation and PavelKunyavskiy, winger, AlexFetisov, Errichto, vepifanov, immortalCO and qwerty787788 for testing the problems! Last but not least, huge thanks to vintage_Vlad_Makeev for his great help in coordinating and testing the round!

Good luck!

The editorial is published!

Congratulations to the winners!

VK Cup Round 2:

- LHiC, V--o_o--V — solved all problems!
- egor_bb, Nikitosh
- -imc-, Golovanov399
- AllCatsAreBeautiful, BanRussiaAtIOI
- aid

Div. 1:

Div. 2:

Is it rated for div2?

Yes

I would suggest closing registrations for now and resuming it after system testing for Round 471 has been done. As otherwise, people currently in Div 2 (who are going to Div 1 after rating update) will register in Div 2 creating a messed up list.

They did that. I think you would be one of those people (who are going to Div 1 after rating update) :D .

Haha yeah! In fact, I realized I just answered my own question from yesterday! xD

Haha It's funny actually.

Wow ,i had miss this , 3 contests in 3 days

I love Codeforces beacause of many contests these days! :)

I wish you successful submissions, many hacks and high rating.

Hopefully you'll enjoy these problems. Wish you a high rating!

Hope it will be not mathforces round

And not Englishforces round. :)

No, no unnecessary stories this time ;)

Thanks. That sounds great. NO Alice and Bob this time!

Three in a row

Is it rated for VK Cup Round 2 participants?

yes

another contest storm , almost everyday , i think it's gonna be contest overflow :D

It is raining contests...!!!

Can we expect 6000 participation today??

Is it just like the last contest, only has three problems in reality? Just be faster.

Well, last time it was at least four.

I was just wondering when the score distribution would come out...

For God's Sake , DO NOT UNRATE THIS CONTEST , I HAVE DONATED YOU CODEFORECES COMMUNITY

It's EarthDay, man

It was on 22nd April , Are you using Internet Explorer ?

Nahh man I'm just using CodeForces' servers right now

A lot of "in queue" submissions, yet

no submissions are being judged. Something is going really wrong this time.UPD:Just seen the announcement. Well, this is unexpected.The Problem States:- "Two ways are considered different if and only if a segment is painted in different colours in them."

"Only if" and "a" ? Then how are CYCMY and CYMCY different? There aren't "Only 1" difference there? If what they are meaning is "Two ways are considered different if any segment is painted in different colours in them." then the problem statement is wrong.

IMO "a segment" phrase has meaning close to "some segment", which is technically any segment

How "only if a segment" and "only if any segment" are same?

I think, when we use

indefinitearticle a/an, we mean "someone", in contrast to "exactly that one".So when I was solving it, I assumed "if and only if" there means (ways are different -> some segment is different) && (some segment is different -> ways are different)

Have you asked jury to clarify that?

"Two ways are considered different if and only if a segment is painted in different colours in them." means "Two ways are considered different if and only if (at least)a segment is painted in different colours in them."

The phrase "if and only if" is used to declare a coimplicative relationship. That is, ways are considered different if (condition), and only if (condition) they are considered diferent (if (condition) is not satisfied, they aren't different). Its meaning is not related to "only one segment".

Anyone knows the

test case 5for Problem C of Div2 / Problem B of Div1 ?I think you need to print output with enough precision.

printf("%.8f",ans) >> WA printf("%.12f",ans)>> AC

Costed me one WA.

But please may i know the reason of the above?

It is considered correct when error is less than 10^-9. (Check the input part) When you don't print 9+ digits it can cause precision errors.

...... 5 WA & can't get accept at the end & wasting time do problem D

My hacks for B:

Answer:

`89/90`

, Wrong answer:`90/99`

Answer:

`-1`

, Wrong answer:`0`

B?

B — VK cup / div1

C — div2

Div 1 B

My hacks for Div2A. I managed to make 8 hacks in total. That includes hacking 3 people twice... Here my tests with correct answers.

Lo_R_D why Wrong answer : 0 ?

`E[i] = 2, E[j] = 3, E[k] = 3`

`answer = (3 - 3) / (3 - 2) = 0`

`j == k`

— wrong.All E_i are different, so in order to be able to pick three of them, E_k — E_i should be at least 2 (since E_j is between E_k and E_i). So all tests where U = 1 have answer -1.

me during the contest ...

How to paste image?

one of my hacks is still showing "In queue" . Will it be counted?

Mine too.. I'm confused..

Yes, this happened with me too in some previous contest but it got counted.

But now it is showing "Ignored". What does it refer to?

No idea

How would I check for which planes could arrive at the same time if they came from the same direction?

Edit: This is for Div 1 D

(X[i] * V[j] — X[j] * V[i]) / (X[j] — V[i]) <=W

You can divide each speed by W, thus getting X[i] * V[j] — X[j] * V[i] <= X[j] — X[i]

X[i]/(V[i]+1) <= X[j] /(V[j]+1)

and the same for >= -w :)

my idea was to find what will be the time taken if wind speed is -w and w and then if 2 planes can meet than time taken by one plane will be more than second for +w wind speed and less for -w wind speed.

Let

t(i,v_{air}) arrival time forv_{air}airspeed. If direction is same, it holds whenx_{i}<x_{j}AND (t(j, -w) ≤t(i, -w) ORt(j,w) ≤t(i,w)).This reduces to finding a pair

i<jsuch thatx_{i}<x_{j},y_{i}<y_{j},z_{i}<z_{j}.Sort by x-coord, and do divide and conquer. Let L a set with

X_{i}≤M, and R a set withX_{i}>M, then we should find a pair such that . This can be done with binary indexed tree. Thus,T(N) = 2T(N/ 2) +O(NlgN) =O(Nlg^{2N})You can get minimum and maximum arrival time for each plane.

Then they can arrive at the same time (if they go in the same direction) iff one [mintime,maxtime] is included in the other.

I didn't manage to count inclusions in an acceptable time during the contest though.

For each plane create a point (

x_{i},v_{i}). Sort all points by angle around point (0,w) and point (0, -w). You get 2 permutations of pointsaandb. You need to find number of pairs of points such that inathe first point comes before the second and inbthe first point comes after the second. It's the number of inversions ina^{ - 1}b, which is a classical problem. You also need to handle the cases when 2 points have the same angle accurately in the comparator.Can anyone please see why my nlog^2n solution for D is giving TLE? https://ideone.com/WGUMhc sorry for bad indexing of part where 2d Fenwick tree is declared though u may skip it as i had directly copied an implementation

Unable to see submission.

Thanks, i have shared new link

RIP T-shirt :(

will the round be semi rated or unrated because of the long queue?

It really impacted some participants including me. I checked my solution of Problem C during the long queue.And finally I didn't have time to code Problem D which I think I can solve it during the contest.

I have solved problem B for Round #471 in a video , the link : https://youtu.be/IG88Al6fWec

and i will solve problems A and B of this contest in a videos

channel link : https://www.youtube.com/channel/UCmWvb73kIq_oRThWd05Mtfg

How to solve div1D. I think we can reduce the problem to count the number of lines that have abs(slope) <= w if each plane is converted to a point (1/xi,vi/xi). How to solve the reduced problem?

if the wind power is -w and two plane meet at p1<=0 && if the wind power is w and they meet at p2>=0 then they are counted

Hello, I want to ask how to solve Div 2 C? My solution is: http://codeforces.com/contest/957/submission/36598579

Basically I fixed for all index k, I want to find the first index i where Ei >= Ek — U, then to maximize the answer obviously j is equals to i + 1. Does the greedy solution above not work?

Please kindly give me corner test case and explanation if you don't mind.

Thank you!

Cant See your solution now but I did the same thing. Hope i pass the sys tests. Did you handle the case of -1?

Noticed my mistake. I think in this case I should fix all index i, not k.

Corner case:

4 10000 1 10 11 15

My solution answers: (15-10)/(15-1) = 0.357142857

Expected: (15-11)/(15-10) = 4/5 = 0.8

del

Does anyone know pretest #7 for Div. 2 D? Thanks

use long long instead of int

For me it was int overflow.

i think GreenGrape can learn how to make a round from you :V Good round guys

Problems were nice, but this doesn't seem good. Almost same amount of people solved ABC.

you should consider that these problems are used in Div 2 round too

You are right, but I think organizers should give more attention to problems and scoring of the official round.

It seems wonderful, what’s the problem?

Go to hell GreenGrape is the best problem setter ever, everyone makes mistakes sometimes your mother for example

how to solve div2d/div1c?

hint : you can draw a line between 2 already drawn lines.

Don't add any new marks until you need to. Keep track of the records where you didn't create a new mark.

Take this case: 0 0 0 1 0 4

Before we see record of 4, ans should be 1. We only created a mark for the first 0 and the 1. Then we know we didn't create any new marks for the second, third, and fourth 0. Now when we see record of 4, we know we need to add 2 new marks on the previous records (not including the current 4).

Now insight is that we should greedily add marks to the most recent records where we didn't create any new marks. This is because if we add a mark for some record, all records after it no matter what will have to contribute +1 to the answer. So we should add marks to the third and fourth 0. Adding mark to third 0 increases ans by 3 and adding mark to fourth 0 increases ans by 1. Now we can create new mark for the record 4 below all other marks, and will satisfy the condition of 4 marks above it. Thus ans is 5. Note that now we should get rid of third and fourth 0 from our list of where we didn't create any new marks.

Since each record creates a mark at most once, complexity is linear.

Maybe a little confusing, I can elaborate more. Also disclaimer I haven't passed sys test.

Edit: passed

you can keep track of the minimum number v of marks that appear after day i.

You know that they are non decreasing, so you can build them from left to right as you read the vector.

Then you need to go from right to left and make sure the increments of your list are at most 1 per day.

With v and m, you can get the minimum number of underwater marks for each day.

In Problem A it states "You are to determine whether there are at least two ways of colouring all the UNPAINTED SEGMENTS so that no two adjacent segments are of the same colour". In case of NO unpainted segments, if the painted segments have no adjacent same colours, it should be yes according to this. Very incorrect and unclear wordings!!!

How to color 0 unpainted segments in two different ways?

I was hacked because of this :(

Semenar is very incorrect and unclear!!!!!!!!

Why there is no penalty for WA on first test, but there is penalty for WA on other samples? :/

i think the concept behind this is the problems that have multiple solution, so if one can't trace his solution he can submit it and see if it's right or not in the first case

In order to give some mercy for people which submit wrong files, for example from different directory.

(I didn't calculate correct complexity, this code runs in O(n))I think that the C test cases is weak.

Check this solution: 36587731

This get ACC, but is a O(n^2) solution.

I think that this test break:

100000 1000000000 1 2 3 4 ... 100000

It's O(n)

You are correct. Sorry xD

It seems like we are going to get new top rated user after rating update :)

Congratulations, Um_nik!

Um_nik is great.

Mystical Mosaic test cases are not appropriate. My wrong code has passed all the test cases. My code gives Yes for this input:- 2 5

## ...

.#...

Why is this running on pretest 1 ? http://codeforces.com/contest/957/submission/36588552

Hi, can some author pls check this my same solution got tle in contest and passes outside.

TLE(during system test):- http://codeforces.com/contest/956/submission/36596404

AC(same code after contest):- http://codeforces.com/contest/956/submission/36601475

MikeMirzayanov or KAN if possible can you please look into the matter and make necessary changes thank you:)

Kind of same problem here. http://codeforces.com/contest/956/submission/36599452 It failed in system testing on a test case it passed during the contest. It passes if i change long double to double? http://codeforces.com/contest/956/submission/36608848

What a code written by xepher52447 ! It takes 30 minutes to test it ! :p

Why is there such a large difference in runtime?

http://codeforces.com/contest/956/submission/36601805

http://codeforces.com/contest/956/submission/36601828

The only thing I changed was reading in integer instead of double. This cost me 30+ minutes and 5 resubmissions ...

P.S. My submission which got TLE on test 7 now passes ...

'P.S. My submission which got TLE on test 7 now passes ...'

You submitted it with different version of compiler

Guess I'm never using C++11 again :|

in problem c in div 2 how the answer of test 22 is 0 ?

I'm sorry, but in test 22 answer is -1. It's impossible that the answer is zero in this problem, because all the energies are distinct

WOW, first time I have full AC due to time extend. Want to say "Thank you" to your electricity supply. :-)

Wow your submission passed in 998 ms :)

Yeah, I'm very lucky at this contest. Instead of reading to an int and typecast to long double, I read directly to long double variables using cin. This process is very time-consuming and many submissions do like this had been TLE. :-)

cool contest... :)

Great... the contest made me need 8 point to 3 point...

.

Has somebody received a t-shirt? Or email about it?-

They said that t-shirts will be sent after vk cup final

Thank you!