Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Reference solution also fails in the edge case of
n = 1
, which should be[0, 0]
because nothing needs to be added:The simplest test case:
which can be solved by
(1, 4), (2, 6), (3, 5)
.Reference solution is incorrect:
max_extra
is provably1
by the following construction:There are only 5 random tests. Incorrect calculation of the first return value can still pass the random tests often.
Source: OJI 2019 XI-XII, Problem 1
Thx for working on my suggestion.
After seeing your solution there is an edge case with two nodes and zero edges. I suggest to put this one in the test suite, if it is not already there.
Cheers!
Thank you for your suggestion, I changed the N to n, and regarding the use of m, I added it as an argument for an easier understanding of the problem and for the examples.
The argument m for the number of edges is almost redundant with the array that contains the edges. You could consider dropping m as an argument.
And a minor one, but in the description n and N are used for the same argument.
It looks challenging enough to give it a try!
Yes it seems I forgot to add this detail, I now stated clearly that the
max_extra
needs to be minimum, thank you for your input.But there's nothing about that it has to be minizimed. The only word "minimum" is in
I did add the minimum number of edges possible. Then
max_extra
is 99 and the description guarantees that it's always the same (it's not the same in general, so it looks like a constraint on input), so I chose an arbitrary solution.Yes it will, but max_extra needs to be the minimum amount of edges added to a specific node so that the graph becomes connected, so u could connect everything with 1 but it isn't a valid solution.
If I connect everything with
1
,max_extra
will be 99, won't it?already far better
Tho, I'd suggest that you show another situation for the second example:
I changed the returned type to List and it seems like I should also add some random tests, especially for ZED.CWT :)
Loading more items...