UPD: Разбор опубликован!
<almost-copy-pasted-part>
Привет! В 04.11.2019 16:15 (Московское время) начнётся Codeforces Round 598 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6 или 7 задач (или 8), которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.
Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Я постарался сделать приличные тесты — так же как и вы буду расстроен, если у многих попадают решения после окончания контеста.
Вам будет предложено 6 или 7 (или 8) задач и 2 часа на их решение.
Штраф за неверную попытку в этом раунде (и последующих Div. 3 раундах) будет равняться 10 минутам.
Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:
- принять участие не менее чем в двух рейтинговых раундах (и решить в каждом из них хотя бы одну задачу),
- не иметь в рейтинге точку 1900 или выше.
Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.
Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацию моей работы. Спасибо моим очень хорошим друзьям Дарье nooinenoojno Степановой, Михаилу awoo Пикляеву, Максиму Neon Мещерякову и Ивану BledDest Андросову за помощь в подготовке и тестирование раунда.
Удачи!
Также хочу сказать, что участники, намеренно отправляющие неверные решения и взламывающие их после окончания соревнования (пример), не будут показаны в таблице лидеров по взломам.
</almost-copy-pasted-part>
thank you for holding a div3 contest!!
Thanks!
vovuh
How to register unofficially ? I clicked on register, but it only allows for ratings less than 1600.
You get a big ugly warning message that you will be registering "out of competition" (i.e. unrated), but you should still be able to click past the agreement and then solve the problems during contest time
solve question ...you will be registered unofficially !!
Imagine vovuh were a super cool meme-lord...then these posts would have had dope memes after the closing bracket and everyone would have literally waited for every Div 3 announcement holding their breath...
Nice time.
A person with a rating of 1599 can enter the competition but a person with a rating of 1600 cannot This makes the second person fall far behind
That's what divisions are all about.
this is my first out of competition contest :)))
Hope it to be like previous div2 597 round contest That was really amazing....
i need only 3 points to be pupil ..please
it will be hilariously sad if you get only two points
it will be really sad if i getdown !
And he got +2. Really sad
F
F
i hope you will get 2 points for this contest ^^
whyyyyyyyyyy
for now 1 point (cf predictor) :)
It seems that you get 2 points.emmmmmmmmmm That's so interesting
Not interesting anymore i really shocked
dislike it if yo wanna lose ur rating
QWQ
10 minutes delay returns
Delayed :/
Перенесли с 16:05 до 16:15?
Походу да :(
I look forward to glory and honor. The competition may begin.
My worst contest ever. :/
I should have solved all, but did fiddling on B for like two hours. Really loosing the fun of this.
delay 10m?
deleted
this was unbalanced one ..
no it was, you think like that only beacuse you did just two problems. Problems were really good!
If you swap D and C it's actually relatively balanced, maybe the difficulty between A and B is a bit too wide though.
I like that contest.
here's no system testing?
No, in div3 and educational contests tests aren't divided into pretests and tests and there are no hacks during the contest time, so your code runs on all the tests during the contest. After that there's a 12hr hacking phase before the final results are announced.
thx!
Does anyone know why a runtime error may occur on 15th test in problem D?
k can be up to 10^12
How to solve F?
If the strings don't have the same letters, answer NO. If some letter appears at least twice, you can swap those two letters to be adjacent, then swap them in the first string and make an arbitrary swap in the second string, therefore we can answer YES. Now assume duplicate letters don't appear, and consider the strings as permutations.
You can do any even number of swaps of adjacent elements to one string without changing the other. Also, every inversion of some intervals either doesn't change the parity of the permutations or changes the parity of both permutations. If the parities are equal, we can make the strings equal with an even amount of swaps, therefore we answer YES. If they are not equal, they cannot be made equal, and therefore we answer NO.
Code: 64228071
Do you calculate parity in O(n^2) ?
You can do bubble sort and count how many swaps you make or check for every number how many numbers are higher to the left.
parity function will check parity of strings if there is no repeated character. That means length of strings should be less than 26 .It is simple pigeonhole principal
lol thanx! I did not get that it is only 26 =)
Number of adjacent swaps can also be calculated in O(NlogN). Although it is not needed here since in that case we have N<=26.
"Every inversion of some intervals either doesn't change the parity of the permutations or changes the parity of both permutations."
How to prove this ? Which permutation is being selected in both of the strings ?
Consider any segment $$$T$$$ of a string $$$S$$$.
There are $$$3$$$ types of inversions
Only type $$$2$$$ is affected by reversing a segment.
If the length of the segment is $$$L$$$ and there are $$$x$$$ inversions, the number of inversions becomes $$$L(L — 1)/2 — x$$$
If the first term is even, the parity remains the same.
Otherwise, the parity flips.
Amazingly, the parity flips based on the length of the chosen segment and not at all on the permutation we use :).
This is a mind-blowing fact :)
Here are my solutions to this contest and here is my detailed editorial :)
Hello div2! Is that you ?
B, C & D are easy to come up with the idea, but the implementation is not trivial, I don't like these kind of problems.
Just get the indexing right, again and again and again. Boring and frustrating.
Honestly, very boring
Problem A? Implementation is not trivial ?
I submitted problem C with MS Visual 2017 compiler (I use Visual Studio 2017), and it gave me WA on the 2nd test case while it's working on my computer and on GNU compiler, I got AC with the same code after the contest.
with MS C++ 2017
with GNU C++ 2017
So I think something is wrong with MS C++ 2017 compiler.
You might be doing something that's undefined behavior
Yep, undefined behavior
Clang++17 Diagnostics says:
p71.cpp:12:7: runtime error: index -1 out of bounds for type 'int [1001]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior p71.cpp:12:7
In
a[qan - 1]
whenqan
is 0Is a solvable with binary search?
Ternary search if you want
How? Can you explain a bit? :) Also why Binary search can't works. Thanks :)
It seems ternary search works.
It can be solved in O(1) time. 64209894
Binary search on the number of coins of value n. So lower_limit = 0, upper_limit = a
if mid*n > total then upper_limit = mid — 1
else find the number of coins of value 1 (total-mid*n). If this value is <= b then "YES" else lower_limit = mid + 1
Code : 64218027
MikeMirzayanov Just a little suggestion from me, could you add contest timer in m1 / m2 site during the contest?
I know that you can estimate the remaining time yourself, but it could be more convenience (at least for me) to see the timer directly. Thank you.
Me too.
If you hack something, will this give you points?
No. Not for Div 3s and Educational Rounds where it is open hacking. But best hackers for opening hacking will be featured in the blog post.
Great Contest. Thanks for this round. Clear Statements! Keep up the good work.
B to D, greedy. Not that standard. D could be harder.
I couldn't access codeforces last 20 minutes. Did anyone have a same problem? I confirmed some of Japanese contestant couldn't.
use lightweight sites (m1.codeforces.com) (m1/m2/m3)
yeah. I faced this for half an hour.
Yeah, my fellow Indian contestants and I were also not able to access the contest, but it was accessible using m2.codeforces.com
I accessed with m1.codeforces.com. But, you can't say the current standings.
Actually, I couldn't reach codeforces even the contest is end. but, I found that some of discussion was posted when we couldn't access codeforces. whats going on!?
That I didn't know before, I guess it must have been a problem for us Asians only.
I had same problem and I thought this contest would be unrated. I tried to access another web site but unfortunately I forget my password. Zzz
Now for B the following is a big hint
Now we need to check in every pass minimum value in between a particular set of indices i to n and place it at front at i and shift each value one step beyond.... for example we have 5 4 1 3 2 now when we traversed for first time we got minimum value as 1 and at index 2 so we swap indices 2 and 1 then indices 1 and 0 to get 1 in front then in another pass we will start from indices 2 to indices n and then find the minimum again as at index 4 then we will swap indices 4 and 3 then indices 3 and 2 to get the final array 1 5 2 4 3 to satisfy the condition that no two indices can be swapped again.
Now FINAL D //C I DON'T TRIED
THIS PROBLEM is almost similar to B but there it is constraint on the value of total swaps but no condition to swap same indices at most once ,SO really this was pretty much simpler then B because what we were required is to get as many 0s in front as possible first I searched whole array and kept track of indices of all zeroes ,now just take as a variable current denoting position and put zeroes in forward of ones until k is greater than 0 for the last 0 that can be shifted find how much values it can come forward with the help of remaining K
greedy and greedy. C and D would have been more classical.
Some swapping problems! I like problem D.
How to solve problem E. I can't get any idea.
Okay, My approach is , first of all sort the array. Now we have to split the array into such sub-segments that each segment is consists of at least 3 numbers. Now, Let our answer be ans. At first we can say that ans = arr[n-1]-arr[0] . Now for each valid splits in position i, we can improve our answer by arr[i]-arr[i+1] . we have to find a set of such i, that summation of all arr[i]-arr[i+1] is as lowest as possible. Let it be Sum . So , our final answer will be , ans= arr[n-1] — arr[0] + Sum . How do we find such Sum ? Just used dp on every i where i>=2 && n-i<=3
I did it like this-
First sort the array
Now the obervation is that each segment would of atleast length 3 and atmost length 5. It makes sense because if we have a segment of length 6 then we can split it into two segments of 3 and we are sure to get the smaller sum because the array is sorted.
now we can use dp , here dp(i,j) is the min cost if we have a segment of length j ending on ith index. Of course only 3 values of j are possible.
Since you could not get idea, I am not writing the complete equations and mentioning only the state. You can look at my solution if you want.
ps: I hope this passes the sys tests too.
Thanks. I got it..
Very nice observation. :)
A very nice lexicographicallySmallestForces contest!
Anyone please tell me what's wrong with my code 64271656 for problem B?
can someone please explain problem E dp state and transition
First, Sort array $$$a$$$ in increasing order. Each team contains at least 3 members and you want to minimize the total diversity of all teams. So, there is no reason to build a team more than 5 members because you always can split the teams (>5 members) into smaller teams and reduce the diversity. Now, you can solve problem with DP technique in linear time.
Let $$$dp(i)$$$ be the minimal total diversity of the school which consists of first $$$i$$$ members.
Transition:
Base case:
Run transition to calculate $$$dp[i]$$$ with $$$6 \leq i \leq n$$$.
The answer is $$$dp[n]$$$. You can construct the configuration by yourself.
Why is loading so slow??? It takes me ten minutes to load a problem
I can't find my mistake... where is "wrong answer each team should consist of at least three students"??? https://mirror.codeforces.com/contest/1256/submission/64279213
In problem E, I came up with the solution using DP but I can't construct the configuration in time =)))
you can construct the configuration after getting the answer, by checking all the state from dp[n] to dp[1],details can be referred to my code.
Thank you, I will check your solution.
Waiting for system test to become blue again...
Edit:FST on C..weak pretests..to be more careful next time..
me too,,,, but it doesn't seem to be system testing.
Waiting to be specialist. But, system testing is going on and on.......
Not today
haha.
In problem C I wrote
p+d<n
instead ofp+d<=n
and passed the pretests... Why so weak pretests?Yeah, really bad pretests in this contest !
congrats. system testing is done
It's not going to be done today. haha
I solved 4 questions in contest and 2 of them failed system testing ! Why are the pretests so weak !!! And that too for a Div3 round this is not how it should be, I understand that while coding one should consider all cases but shouldn't that be tested in Div2 then?
It's the first time I become Expert, I'm so happy now =)))
Congrats
How could a O(n^2) solution passed for F? I don’t get it. Please someone explain it to me. TIA.
Well, if string has 2 or more equal letters in it, then the answer is YES. In other case the length of string is not more then 26
Thanks man. I got it.
why i receive a runtime error by using stl?
problem D (div3) https://paste.ubuntu.com/p/9rbHFmBcMP/
I have a doubt regarding the problem "Minimize the Permutation". My approach was that I iterate from 1 to n and try to bring the smaller elements(from 1 to n) forward, and do the same for next element if, I have either brought my current element(say i) to the 'i-1'th position or I could not swap it anymore(to bring to a lower index) for that I maintain a 'swapped' vector.
But, my solution didn't work because I didn't add the condition "arr[j-1]>arr[j]" for the while loop(i.e we have to swap only if the element on the left is bigger). And works fine if I add it. Can you please help me understand that why do we need to add this condition, is it not obvious? Can someone please explain to me with a small test case?
This doesn't work. This works.
Yes bro , I have experienced same issue. Can anyone please explain the above with a small test case ?
consider the case: 4 4 2 1 3
But that is not a valid permutation according to the question. Read it again.
the permutation is [4, 2, 1, 3]. The first 4 is the size, and my line-breaks were eaten. After the first iteration of the number 1 and number two, it is ok that the sequence turns to [1, 4, 2, 3]. In the second iteration, 2 will not be moved because there has been a swap in the first iteration. It gets into trouble when a new iteration of the number 3. 2 and 3 would be swapped if you do not compare them, and the result would be [1, 4, 3, 2].
Thanks bro!