Hello Codeforces!
On Jun/10/2018 13:05 (Moscow time) Educational Codeforces Round 45 will start.
Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.
This round will be rated for the participants with rating lower than 2100. It will be held on extented ACM ICPC rules. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.
You will be given 7 problems and 2 hours to solve them.
The problems were invented and prepared by Adilbek adedalic Dalabaev, Roman Roms Glazov, Ivan BledDest Androsov, Mike MikeMirzayanov Mirzayanov and me.
Good luck to all participants!
Congratulations to the winners:
Rank | Competitor | Problems Solved | Penalty |
---|---|---|---|
1 | KrK | 7 | 225 |
2 | isaf27 | 7 | 231 |
3 | BigBag | 7 | 325 |
4 | Motarack | 7 | 327 |
5 | TangentDay | 7 | 331 |
Congratulations to the best hackers:
Rank | Competitor | Hack Count |
---|---|---|
1 | halyavin | 202:-52 |
2 | 2014CAIS01 | 26:-2 |
3 | djm03178 | 20 |
4 | bitcoin | 19 |
5 | antguz | 25:-17 |
And finally people who were the first to solve each problem:
Problem | Competitor | Penalty |
---|---|---|
A | tzuyu_chou | 0:01 |
B | DoomzGay | 0:05 |
C | 562225807 | 0:08 |
D | teja349 | 0:12 |
E | eddy1021 | 0:18 |
F | nhho | 0:45 |
G | AChen142857 | 0:14 |
UPD: Editorial is out
Good luck to all!
Starts at unusual time :)
I can finally participate in a contest without staying up late as a Chinese.
Welcome back BledDest!
During 20:00-20:05(BJS), I have my left hand on a computer that open Codeforces, and my right hand on a computer that open Atcoder.
There is a hacking phase too in this round so we will be very busy around 1205(UTC) lol
Also if there something happens, they will have to increase contest time. Which is unfortunate from every angle.
Sometimes only for unusual time many regular participants can not participate...!!!
Thank MikeMirzayanov for codeforces and polygon platform. :)
Yep! We remember well what happened last time this statement was not included :) http://codeforces.net/blog/entry/59720?#comment-434084
Tester halyavin haven't registered yet)
Don't worry step_by_step has :P.
Last Educational round step_by_step had most hacks 248.
Is it rated for Div. 3 then?
Div.3 is just a part of Div.2 so it is rated for Div.3.
Is it faked?
Finally, a contest after more than a week of non-practicing :D
Contests with hacking phase make me nervous before even participating.
The one in which solution can be hacked on some base cases rather than edge cases :: Educational round.
So, think 4 times before submitting
the "education" in educational rounds stands for that.
If I think 4 times, contest would already be over :p
Done with semesters finally!! Wishing higher ratings to everyone including myself :P
For me, it is first time contest starts in reasonable time zone. (19:05 KST) I was struggle on midnight-beginning contest heretofore :)
float ship; // must be a float otherwise ship sinks
I couldn't help but notice that people with rating >= 2100 are not marked as out of competition.
"Educational rounds are rated for users with rating below 2100, but it doesn't mean other users are unofficial. I think, In those rounds all users are welcome to participate officialy."
This time is friendly for Chinese!
That's true. Also it is for all people living in the Far East)
I agree with you, but there is a spelling mistake.. Think of "int mian" "inlcude" "isotream" and so on.
oops...I didn't notice that spelling mistake.
Can someone explain what are the extended ACM ICPC rules? In what do they differ from the regular ACM ICPC?
The differences are the hacking phase afterwards and full retest on the final set of tests with the hacks included.
For problem D.. the only "NO" testcase is n > 1 and b > 1 .. is this true ?
I think answer is NO for n = 2 and a=1, b=1, also n=3, a=1,b=1, and min(a,b)>1.
I think its NO when neither of them is 1 or if both of them are 1 (except when n=1) The rule here seems to be that either of G and H will be connected (either of a and b must be 1) ^Not sure if it's entirely true though
Both of them can be connected at the same time also. (Consider the graph 1--2--3--4 with 4 vertices and 3 edges)
Oh yeah you're right
I wonder what's the matter with problem D?
I forgot when the a==1 and b==1... how foolish I was!
Give me some strong test case for problem C
1
)(
What's the 3rd test case for problem D?
5 1 1
The Answer for this is NO right?
Chain 1-2-3-4-5 satisfy this i think
Answer is yes. (1-2, 2-3, 3-4, 4-5)
Can anyone tell me how many points will I get for successful hack and how many I will lose for an unsuccessful one?
none. in educational rounds there is no points for hacking
Then I don't get what's the point of giving 12 hours for the hack, if there is no point for hacking, I mean at last they will check each code on their test code then why 12 hours for hacking. @Infinite_M can you please explain. I am actually a beginer here.
There is a point. You can increase your rank if you hack solutions of people ranked above you ;)
All successful hacks will be added to system tests. existing test cases don't guarantee that program is correct.
[user:killer_good] Can you please clarify this point? I was in an impression that codeforces provide some basic test cases to check code during contest.But they do have a test file including all corner test cases(like other websites , codechef,etc) after the contest they run every code through these test files(including corner test cases). is it true?? Or They just prepare base test cases on which they check submissions during contest and let participants find the corner test cases during hack??I mean don't they have test files for possible corner cases?
for normal contests what you said is true. but for educational round system test will consist of successful hacks from users that's why we have a separate hacking phase unlike other contests.
User Fortza_Gabi_Tulba submitted F(39097227) at 00:28, and submitted E(39097570) at 00:29.
Since it is (almost) impossible for human to solve and code problem F in only one minute,
does it mean he submitted problem F while coding problem E?
Or he coded E and F, and then submitted F and E?
Or, is he a genius?
same thing for problem B(39091953) and D(39092747)...
I doubt if Fortza_Gabi_Tulba coded with friends...
Тhe style of these codes is also different.
Some coders such as tourist use this strategy sometimes.
tourist does not do this in codeforces. It only makes sense to do this in judges where the penalty is calculated by the time of the last submission, which is not the case of codeforces where the penalty is calculated as the sum of times of all accepted submissions.
So here it is better to submit a problem as soon as you coded it, and not doing that is suspicious.
Fortza_Gabi_Tulba is a joke account.... Gabi Tulba is purple on codeforces. Take the joke
Bloody build stupid graph for a=1,b=1 and n>=1,damm i should have check more carefully for problem D :(.
Test number 31 on problem F is not correct. It has n = 1, while this is not possible. According to the statement m >= 1 and you can not have non-zero m for n = 1
Yes, sorry, there was a mistake in the statement. Luckily, no one got problems on that test during the contest.
test case 10 in C?
Just open any solution which has reached to test case 10.
It is almost impossible to understand from someone's solution what I am failing at as my logic can be different than to the referred code.
When you open a solution you can see test cases it has reached:
75000 (()) )(( ())) ))() )((( ((( ))( ())) )() )))( ()(( ))) ((( )((( )((( )() ()(( )((( )() ((() ((( ))( (()) ))(( (()( )() ()) )(( (((( ))() ))) (() ()( ((( )((( (()( )((( ()( ((( ())) )(( ))() ((( ()) ())( ))(( ()( )((( (((( ()() ())( ))) (((( ()) )()( (()) )(() ()() ))) ))( ))( ()) (() ))(( ()(( )((( ()) )()) )(() ()() ()( )))( )(( ()) (() ))(( ()) (()( ((() ((() ))( ()( ))(( )(() ()( (() )(( ((() )()) (()( )(() ...
Perhaps that will help.
If you open a solution, you can view all of the test cases that solution has reached. Just scroll down. That's what Emil_PhysMath meant.
thanks, I did not know that!
Do note that it only works out of contest :)
You must not include cases such as )( or )((() in your answer
yes i have done that.
First contest during travelling ^_^
I was suffered from the word in problem A "commentary delegation burle demolish blahblah" I should study english more :(
How to solve E?
Just precalculate for each street index the index just lower or equal where you can place the lamp-post. Then iterate over all possible values of powers and compute for all values the mincost by directly jumping to the place where you place next lamp-post and take minimum over all these. 39119701
Why O(nlogn)? I can prove only O(nsqrt(n)).
Proving that for power i it needs O(n/i) should be enough. Let us say that we are computing for power i and length n. Now, say there is a lamppost at position l and the next lamppost be placed at r now even next lamppost must be placed at least l+i, clearly except in the case that it is not possible to illuminate the street. So there should be atmost about ~(2*n)/i iterations.So, the complexity should be O(k+nlogn). Please correct me if something is wrong.
First check the maximum count of consecutive blocked positions, if this count (let this count's name be maxcon) is >=k or if the first position (0) is blocked then the answer is -1. Then search for the cheapest power starting from maxcon+1 to k. For power i, you will calculate its cost by putting its lamps greedily starting from j=0 and moving with j+=i, but if you reached some blocked j you should change j to the value of the last unblocked position before j (as if you were putting this lamp in the last unblocked position before j not in j itself).
For the 1st test case,
6 2 3
1 3
1 2 3
Can't we use the lamp with power 1 to light the whole street?
If we put it at position 0 , it will cover [0,1] . then at 2 covering [2,3] , then at 4 covering [4,5] and at 5 covering [5,6]
That way the total cost will be 4, which is cheaper.
You need also to cover the segments [1, 2] and [3, 4]. There was an announcement regarding this during the contest which was:
"You have to illuminate the whole segment, not only its integer coordinates. For example, if n = 3, illuminating [0, 1] and [2, 3] is not enough."
Oh! Didn't notice. Thanks
can I get the rating in this round?
Does anyone know solution for G? My solution keeps getting TLE on test case 95, and I think mine has O(n log^2 n) time complexity and I can't think of any better solution. I used centroid decomposition
This should work, because there are only log(ai) different values of gcd, so complexity will be n*log(ai)^2.
Thank you. I was thinking too complicated solution, you are very smart
can you please explain the idea a little bit.
Intuitively I felt that there should only be around log(ai) different values of gcd, but I can't think of a good formal argument for why that is true. Do you have any good proof for it?
Hacked huh. There are actually O(divisors) gcd values for paths (think about a leaf for every divisor and the rest of the tree has the same value). What you were thinking about is another thing, there are at most O(log) CHANGES of gcd in a path.
So your solution is actually O(N * maxDivisors(2e5)^2) along with bad constant from using map (mostly chache misses I guess).
It works, just forgot to clear maps after using ;w;
http://codeforces.net/contest/990/submission/39135974 I submited the exact same solution that got hacked and it passed in the same time as before the hack hmmm.... Looks like that hack didn't get into systests lol
Edit: we can see the hack now http://codeforces.net/contest/990/hacks/458169/test. I tried to test it locally and the second code crashed in my computer (probably couldn't handle the memory lol). Maybe someone could add this test to the test set? This is a intuitive solution that has already appeared in codeforces but with downward paths only iirc, I wouldn't be surprised if a similar solution passed systests just because it didn't got hacked.
Edit2: I tested it in a custom invocation and the second submission passes in a bit under 4 seconds (ignoring input) and without the clear it's MLE. Can someone prove a lower bound than what I said for this solution?
Edit3: the hacker that did this did most hacks for G http://codeforces.net/contest/990/hacks?chosenProblemIndex=G and the test didn't get added. Hopefully he didn't miss anyone :P
Edit4: this case was added!
Hey, can you explain your approach?
For each i, compute h(i) = number of paths that have value multiple of i. For each i, dp[i] = number of paths that have value exactly i = h(i) — dp[i * 2] — dp[i * 3] — dp[i * 4] — dp[i * 5] — ...
I was getting wrong answer in D coz I printed
YES
0 1 0 0 0
1 0 1 0 0
0 1 0 1 0
0 0 1 0 1
0 0 0 1 0
instead of
YES
01000
10100
01010
00101
00010
basically the same result with spaces. Shouldn't that be allowed to pass?
Only trailing spaces are ignored(I think)
what I did in C was ignored all cases of brackets which gave )( this sort of thing, and kept a count of regular expression brackets, then if suppose (())), then this one has 1 closing bracket more, hence it will require any bracket sequence which has 1 opening bracket (such as (, (() or many like this)
I iterated for every sequence if it was a regular one, I added the total number of regular ones in the list given. If it was something like (())), which means it requires one open one, hence I added number of sequences with one open bracket, and when I came to the bracket with one open required, I ignored, hence I only calculated for the regular and closed ones, as open would be covered while doing for closed ones.
Can anyone suggest me what am missing?
I don't understand your solution
what I did in C was ignored all cases of brackets which gave )( this sort of thing
Do you ignore "()( )( "? Then your program won't count ()( )( + )( )() as a regular bracket sequence.Nah, I ignored the ones which has )( both
At last I found it. Your program gives wrong answer to this test case. I hope it will help:)
2
)()()(()())
(
1
0
thank you. I was also stuck on the same test case.
You're welcome:) I hope it will help you to correct your code.
I saw one of the test case of Problem D is 1 1 1, which means a graph with just one node.
The correct answer is "NO", can anyone explain why there is no answer when n = 1?
Answer is YES http://codeforces.net/contest/990/submission/39099219 #6
forgive me, I misunderstand it.
It's okay XD
Remember to use long long everywhere, even though you think that it can't be over 2^31. Especially when you can't find your mistake anywhere.
That is my strategy!!!
Once this slowed my solution down to make it get TLE though so it's not a strictly good idea
Yeah you are right. But once on a USACO contest I got WA. Then I changed only one variable(I thought only it could cause a WA) to long long and again got WA. After the contest I read the editorial and the solution was suspiciously similar to mine. I changed all variables and got AC:(
After that changing int to long long is the first(or maybe the second) thing I do after getting WA.
What is the solution for D?
Connecting vertex to all others means that this vertex will make isolated component in graph's complement. So if
b > 1
, you needb - 1
vertex connected with other vertexes in main graph. Ifa > 1
, you need complete graph onn - a + 1
vertexes, anda - 1
isolated ones.For the second case I think you meant complete graph on n-a+1 and a-1 isolated ones.
Yeah, sure, thx :)
Can one hack this solution with making an anti-hash test? http://codeforces.net/contest/990/submission/39097287
Yes.
I'm sure halyavin can do it.
Probably not because the constraint on the input is a[i] <= 1e6 so there aren't many numbers to create collisions.
Unordered map doesn't use a fixed hash fucntion so it's "improbable" to find a hack.
I once got several WAs in a problem because of a test designed to break unordered_map hash. Isn't it the same for hacks? Or does testing behaves differently using a fixed seed?
awoo For the Problem B, I submitted this in C++ 11, it gave me a wrong answer. Then I submitted the same code in C++14 this and got accepted.
Because of wrong submission I had to face a penalty. I think this is wrong and it should be removed.
The code has an uninitialized variable. In test 3, there's nothing assigned to the variable 'got' in the binary search code. You can initialize it with a specific value and see what happens.
you're right since your code has a mistake 2nd submission should be ignored.
I don't think any action would be taken by MikeMirzayanov and CF admins. I hope they take decision in my favour, if they do something. Well I enjoyed the contest, though I didn't perform well. I think next round would be favorable.
Are there any editorial now?
after the hacks
Why this 39120549 fails while this 39119719 passes for problem C?
I don't think
op[N]={}
initializes an array with zeroes, but I thinkop[N]={0}
do.Even that failed. 39127177 . I am unable to understand the Diagnostics. Can someone check the Diagonostics of the above solution and explain to me. Thanks.
it actually does. Not an undefined behaviour.
You are writing in an empty string (st) without changing its size, so it's undefined behavior. When stuff like this happens it's usually because you allocated the memory badly.
How to solve F? i figured i would put in a super source and a super sink to reduce it to a max flow prob. But complexity for solving flow vector is too bad
Notice that if we add a cyclic flow on a valid flow, it's still valid. So, if the graph has cycles, we can use cyclic flow to zero an edge on the cycle, effectively removing it. Repeatedly remove edges from cycles until the graph becomes a tree, and then the problem is pretty simple.(recursively solve it from leaves) Complexity is O(n).
I didn't solve F at contest but shortly after the contest I figured this out. Hope that I am correct.
Update: confirmed it works
Beautiful solution, thanks! I just submitted using your idea and can confirm that this indeed works
why if sum !=0 test incorrect? This test looks correct.
Look at the bottom right node, it has a netflow of 9, and not -9. As for why the sum should be zero, you are flowing from one node to the other, so the net inflow must be equal to the net outflow
oh, my mistake, ty
Why My solution for D is wrong??
http://codeforces.net/contest/990/submission/39122954
If you scroll down, you can literally see the test together with the message "wrong answer The number of components in the complement graph should be 84, but found 1"
when will the ratings be assigned regarding the educational round.
after hacks
was this round rated for Div 3?
for everyone below rating 2100 as mentioned
Awesome educational as usual, but I think two hours might have been a bit too little for seven problems. Most people didn't have the chance to work on F or G, which is a pity considering they were good problems.
Yes i worked out problem E as i found it was greedy and almost wrote the code but just needed 5 mins to do some case testing.
I can't figure out why my solution hits the time limit. It should be O(nlog(n)). http://codeforces.net/contest/990/submission/39097135
Brother i don't code in java but as i have seen several times in codeforces comments that arrays.sort() has a worst case complexity of O(n*n).
Sorting Primitive types in Java uses quick sort so it takes O(N^2) in worst case. It's actually common for some reason to always include these anti quick sort tests in codeforces problems.
To get around these you can do two things, declare your types as wrapper class (i.e Integer instead of int) so it becomes an object so runs in O(nlogn), or shuffle the input array.
Thank you, I will try that tomorrow, I have never had that kind of problem before.
How to solve E if a lamppost of power l were to cover [x - l, x + l] ??
So it turn out we can shift the lamppost to its left end in this segment to cover [x, x + 2 * l] only if [x + l] was not blocked and the problem just reduces to the same version in here.
This idea was suggested by lrvideckis :)
Fck myself. I was trying to solve this problem during contest. And couldn't create solution. So I decided to solve G instead.
Only after your comment I reread the stamenent. (((
trust me you're not alone :'( I had the same misconception about this problem :|
The tragedy of every educational round.. waiting for the final test and the rating change.
How long do i have to wait to get my rating?
Until the admins of the contest wake up! We need to wait for final tests.
Well it's 10:10pm here so I will simply go sleep soon and check the next morning instead of worrying about it now. :P Good night!
when will rating change ?
Well if you cannot wait to see the final result, you may submit your code in the archive and see how it works.
Can anybody explain me the strategy used to start solving Problem C or any similar question question's hint or link.
One bracket sequence can be:
Good.
Need some left brackets ( to make it good.
Need some right brackets ) to make it good.
Can never be good.
Then you can do bracket matching algorithm to determine which type one sequence is and how many left or right brackets that can make it good. You can see my code at http://codeforces.net/contest/990/submission/39098111
A bracket sequence will be regular if, starting count from first character, for any position of that sequence, number of opening brackets "(" is more or equal to the number of closig bracket ")" ,and finaly number of opening bracket is equal to the number of closing bracket.
Now , if you want to make a regular sequence by concatenating two sequences , there will be some options
1.choose two regular sequence
2.choose one sequence that have n more opening brackets(here n=total number of opening brackets-total number of closing bracket) .and for any position of that sequence number of opening brackets are not less than number of closing brackets.and choose another sequence that have n more closing brackets than opening brackets (here n is similar to previous one).and for any position of this sequence number of closing brackets should not be more than n+number of opening brackets. now you can concatenate these two sequences in one way , 1st+2nd will be a regular sequence .
[Don't know how much I could explain , sorry for my bad English :) ]
why my rating hasn't change until now? How long does the change take after the contest finished?
We have to wait for the problem maker to wake up.
Why couldn't system tests start automatically?
It’s really annoying to wait for rating changes after completing Hacking phase in every Educational round. please @MikeMirzayanov solve this.
Do you know that there is a chrome extension for codeforces? You can check the expected rate change quite precisely.
The issue, system tests have not happened yet so expected rating change is not final.
after round 487 there will be no contest for 5-6 days and it's not good
Can anybody explain how to use generators for hacking ?
It requires a code that prints out the test case to stdout. i.e. Use printf / cout to make a test case.
http://codeforces.net/contest/990/submission/39138201 can anyone help me finding whats wrong with my code for F?
Will the ratings beupdated after today's contest?
Auto comment: topic has been updated by awoo (previous revision, new revision, compare).
@ MikeMirzayanov regarding submission for the question b.microworld my submission is http://codeforces.net/contest/990/submission/39094917 it is getting correct answer(in local g++ compiler) for the test case which is showing as wrong output in the system run for one test case. this is looking very odd.
can you please look into this, and also wanted to know if any one facing same.
adedalic Roms BledDest can anyone respond to this.
ar.size() - 2
can underflow (unsigned), which results in a large value and you access the array at that value, i.e. undefined behaviori think that case wont be arrising. please check by running , i checked it.
test case: 1 1 1 output: 1
@yassin_ reply please??
It's undefined behavior, results can vary for different runs or compiler versions
Test 15 as you can see is: 1 1 1 and your solution gives: -1199 what is definitely UB. It seems like it is caused by
ar.size() - 2
.@adedalic I checked it using local compiler and some other online as well which are working well for that input. can you once check it once by running the code. since i dont feel some thing undefined should be occuring for this code.
who are down voting this,..please explain me whats wrong in the code.(which is working fine in other compilers )
yassin_ adedalic
so you guys are saying problem arise at ~~~~**~** while(n1>=0&&ar[n2]-ar[n1]<=k&&ar[n1]!=ar[n2]) ~~~~~ line 30 of code where compiler runs differently for this line. is it??
when will ratings get updated???
ratings updated. Just saw it
How is rating change determined here?? Pls help.
http://codeforces.net/blog/entry/20762
I want to become purple...
Auto comment: topic has been updated by awoo (previous revision, new revision, compare).
My following normal cin, cout solution for problem E timed out on test 6 as it was not able to read the input.
http://codeforces.net/contest/990/submission/39115276
whereas the following solution with ios sync passed.
http://codeforces.net/contest/990/submission/39145593
Is this justified?
Your crafting.oj.uz ratings are also updated!
We are seeking for a way to somehow differentiate the performance between the first and the 100th user, since currently both are the same because of the low $RATEDBOUND$s. If we just raise the bound, everybody's rating seems to be increased and this problem just occurs again.
Can anyone explain the logic behind the editorial of Problem C?