Hello!
Codeforces Round 494 (Div. 3) will start on July 3 (Tuesday) at 14:35 (UTC). You will be offered 6 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. Probably, participants from the first division will not be at all interested by this problems. And for 1600-1899 the problems will be too easy. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially.
The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over.
You will be given 6 problems and 2 hours to solve them.
Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as a trusted participants of the third division, you must:
- take part in at least two rated rounds (and solve at least one problem in each of them),
- do not have a point of 1900 or higher in the rating.
Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.
Thanks to MikeMirzayanov for the platform, help with ideas for problems and for coordination of my work. Thanks to Mikhail awoo Piklyaev, Maksim Neon Mescheryakov and Ivan BledDest Androsov for help in round preparation and testing the round.
Good luck!
UPD: Editorial
UPD2:
Congratulations to the winners:
Rank | Competitor | Problems Solved | Penalty |
---|---|---|---|
1 | peanutpedo20 | 6 | 194 |
2 | Sakurak | 6 | 363 |
3 | Mr.HP | 6 | 404 |
4 | CrownJJ | 6 | 417 |
5 | Skypiea | 5 | 153 |
Congratulations to the best hackers:
Rank | Competitor | Hack Count |
---|---|---|
1 | Osama_Alkhodairy | 32:-3 |
2 | Al-Merreikh | 26 |
3 | SovietPower | 23:-1 |
4 | neelbhallabos | 22:-2 |
5 | Milkdrop | 20:-3 |
419 successful hacks and 670 unsuccessful hacks were made in total!
And finally people who were the first to solve each problem:
Problem | Competitor | Penalty |
---|---|---|
A | Skypiea | 0:00 |
B | Rinne | 0:08 |
C | quality | 0:10 |
D | adamgibiadam | 0:11 |
E | peanutpedo20 | 0:39 |
F | peanutpedo20 | 0:55 |
Thanks for another div 3 contest!
I am new here,please somebody give me some info/links on these rounds so that I can explore the site. thanks
Hi, you can go to the contest section.
Thanks i looked into it. Please clear what are systests.
System tests are the exhaustive test cases which are fed to your solution. They cover much more corner cases which are not usually shown in the sample test cases. One must design his/her solution keeping every possible corner cases in mind to pass the System testing phase.
there rounds to solve problems and to your Score will be your rate
ex : If you didn't solve any problem your rate on website will be lower and vice versa
After rounds There's Systests So Probably Solve Problem and Got Wrong Answer in Systest and There's in this Contest Hacking phase that You Can See Other Codes and if you found something wrong you can Hack him.
You Can find previous Contests in contests Section
yes thanks. i found the virtual contest mode very interesting. it's just live as you really attempting the original contest. loving codeforces.
Every time you prepare a CodeForces Div3 round, I feel that you always copy paste this blog :| Anyway thanks for the round.
Hope this time we get all questions of expected difficulty.Best of luck to all participants :)
How many of you agree that the phase of open hack must be reduced to 6 hours as most of the hacking happens in this time and also the penalties on wrong submission to +10 mins instead of +20 mins which I think for a 2 hr round is too much.
it should be just during the contest as i see div 2 rules
in regular Contests Hack is during Contest
But This contest with Eduacational round rule So There's hacking phase
I love div 3
what is so special in it,it should be taken as a challenge to move up.
hope this contest has strong pretests... :)
Aren't you a guy who wrote about "a lot of hacking stuff" on previous contest and got a lot of downvotes? ;)
yes...i realized that people don't want that....and so my hope changed..xd plus i wish my contribution is positive as it had become negative due to previous comment..
also i don't like this type of hacking phase where the questions trip down after the contest..hacking phase should be through the running contest with points being awarded for corresponding hacks, so that people may come to know that there solution is incorrect and at least resubmit correct solution after hack.
To practice acm questions click here
It is a matter of taste, yes, it is a large ACM archive, but there are a lot of other)
I just wanted to be resourceful for the community and there are many for whom the link might be useful for practicing for the future codeforces contests.Here the testcases are quite well!
Depends on a problem: some problems were rejudjed because of bad initial testcases, but yes, it looks more like an exception, not a rule
bbbbbbbbbboooooooooooooorrrrrrrrrrrrrriiiiiiiiiiiiiiiinnnnnnnnnnnnnngggggggggggggg
Why you comments so Stupid!
people should respect a person competing regularly and is so active from war trodden syria
My rating of 1596 is quite embarrassing... Maybe I can be Expert after this round!
Avtakhov's rating point is even more embarrassing, so is the rating change.
.
Div. 3 contests are really awesome! But I think, if the difficulty level between 'C' and 'D' is made more balanced then the participants( specially the beginners ) would get more motivated :). Best of luck to all.
r U smart?
r U smart?
isit unrated?
Yes unrated for unrated
unrated for unrated but unrated is rated. fallacy
I request Mike to increase Number of div3 contests coz number of div2+div3 guys are more than div1
MikeMirzayanov
I am excited to see div2 + div3 contest someday :)
the div3 was introduced for seperating div2 into 2 divisions. no need
All Div2 contests are actually Div2+Div3
It's Div.2
what is tba
To Be Announced.
its div 2
No,Div.1 is very few,It's hard for red and orange coder to take part in the contests And Div.1 always appears with Div.2, the number of Div.2 is enough.
Guys can anyone tell me how to automatically generate tests ?, I read something about that long time ago but I can't find it right now.
If you want to generate random test cases of your own, use this website to do so
Polygon has its own test generation system. Check (EDIT: for some reason, the link isn't working, so instead go to https://mirror.codeforces.com/testlib and on the right you'll see one of the blogs has a russion title; that's the one you're looking for.) to see how the generators work. Note: it's in russian, so you'll probably need to use google translate to understand it.
Hopefully, problem set will be an interesting and short description. Good luck with the high rating.
Cant submit anything
Bad Gateway 502 again and again :( Such was not expected
Hello, I have been getting 502 error and codeforces unavailable for 8 minutes now, and not sure when this is going to end. Can you please make this round unrated for me, i feel this time penalty is unfair to me.
500 / 502
WTH??? Contest page hasn't been working for past 3 minutes..Lost my ratings too :(
Sorry for 502 on the first 10 minutes of the round. I think I investigated the reason. It is fixed now. I think it is because of filter for trusted participants. I've temporarily disabled it.
Site is not opening on my computer. I am unable to make submission for the last 45 minutes. The round should be made unrated. I wrote this from mobile phone site.
There is no score distribution?? :o
Div 3 is based on ACM ICPC RULES (Extended). So there is no score distribution. Each problem is of equal weightage with a time penalty according to submission time and no of wrong answers.
the predictor isn't working in Div3 contest again !
[UPD] it is working now .
So, I lowered the rating, but the tasks were very good, especially D, thank u, vovuh, for this contest!
In my opinion it was the best div3 contest)
Can we submit multiple times?
how to solve E ?
Very interesting problems this time!
Div 2 Round .. Solves A,B,C. Div 3 Round Solves only A and D.. What madness lol.
Nice problems, thank you!
I suggest having an announcement right after updating some mistakes . In problem F , it shows(j1 > i1) at first , and I thought the number of words must be exactly bigger than 1 . However it changes and I haven't update my webpage , which leads lots of WA on test4 , and I don't have enough time finding the rest bugs .
Another sad thing , my bug is using "srand" , can anyone explain why it may gets wrong by using srand and rand ? PS:I used time(NULL) as the seed
Same with j1>i1 :D Strange that they haven't made clarification.
I'm really sorry about it. I personally can not publish global announcements, they can be published by Mike or Ivan (BledDest), but they were very busy, and I just fixed this mistake and forgot to ask Ivan to publish this fix in the global announcement. I'm very sorry for my terrible mistake and I apologize to RDDCCD, Tutis and the others who were affected by this bug.
Could any one help me by pointing out my mistake?code link-http://mirror.codeforces.com/contest/1003/submission/39925516
Really?
yeah that was my bad please help now-http://mirror.codeforces.com/contest/1003/submission/39928710
k can be between k <= i <= n, you only considering segments of size 'k' and 'n'
Div3: a wolf in sheep's clothing.
When will editorial get uploaded??
May be after hacking phase ends.
I'm unable to understand whats wrong in my submission on problem D .can anyone help me ? http://mirror.codeforces.com/contest/1003/submission/39928159
Try lli (aka long long int) rather than li (aka long int, it is actually the same as int).
thanks! but can u tell what is causing this mistake ? as if I'm running in my pc system it gives correct answer but on codeforces system, it is giving dump value.
it is cause of long long( just change (li ans=0) to (lli ans=0)
Can we use greedy approach in D??
Yes Greedy will work.
Yes. Greedy approach always works when the numbers in the sorted order are the multiples of numbers before them in the array.
I think there was a problem on the problem C ! I tried an O(n²) in python but i got a time limit error while the same code in cpp passed the pretest... Could you make little changes please for that all the .py code passed the pretest such as the ccp code please ?
The same code is judged as correct in PyPy and judged as wrong in python 3.6 !
I hope that my submission and the others like mines are going to be corrected...
I'm more curious as to why the latter submission took almost 13 times more time to execute
first of all there is a difference between wrong and TLE. And pypy is an optimised intime python interpreter. so you should always submmit your sol. in pypy because it is fast. although there is a disadvantage to it, that it consumes a lot of memory, so only if you get MLE submit it in python. It is very rare to see python working faster than pypy
Now i won't continue to use python 3.6 as interpeter but i'm very dissapointed. I will loose rating (probably such many other persons) juste because i used python 3.6 s interpreter. I think that's not normal and I really hope that Codeforces Admin will make something to change that.
Dude python is not a recommended language for competitive. But yeah it is quite useful in some questions. By the way in this question python also passes, you should try optimizing your code
but where is the egality if the O(n²) passed in other language ?
Then use the other language. Language equality is an illusion. Join the cult of C++
Some languages are faster than others. Also, some compilers/interpreters are faster than others. It's not the fault Codeforces and it's up to participants to know these things and to be able to judge which language/compiler/interpreter is approproate for which task.
You may done this in O(n) time.
code
Can you tell a little more about the O(n) approach?
Let us denote .
And
Let yi = S[i - 1], xi = i - 1 then what we want is to maximize the slope of lines that cross two points (i, S[i]), (Xj, Yj)
This is an ordinary model, which we can simply maintain a convex hull, and a deque to solve the problem.
Doesn't maintaining a convex hull take O(n*log(n)) complexity? And hence the total complexity of the above would be O(n*log(n)). Please correct me if I am wrong CelesteLight.
The decision is monotonous.(my English is poor)
Because we know that Xi, Yi are both increasing. And we can prove that if
then
So we can pop the last point of convex hull if the next one is better. And it is $O(n)$
Ohk, that was good.
Can you give pseudo code or the AC submission of this algorithm and similar to this
http://mirror.codeforces.com/contest/1003/submission/39957991
Here is the code.
CelesteLight I am trying to understand your solution without looking at your code implementation. Sorry I am not very good at Math, especially the Math term in English, can you help me understand the following:
1) what do mean by "ordinary model"? Do you mean degree 1 polynomial?
2) I understand your explanation up to the point of finding the slope of (i, S[i]), (Xj, Yj). So, the naive solution is to find the slope of every pair (i, j) , which will take O(n2) . How does convex hull algorithm helps reducing it to 0(n)?
a) To clarify my confusion, when we build the convex, we will go from point to point: (i, Si), (i + 1, Si + 1). How will that reflect on (i, Si), (i + k, Si + k) which is the range that we are interested in?
My English is far too poor to explain it further. If you want to know more, searching in the Internet for "slope optimize DP" might help.
Website issue cost me rating
After submitting A, I had to wait around 8-10 minutes to read the problem statement of B.
This happened to everyone, and I think now noting can be done.
And further questions B,C,D were also good. 10 minutes does not matter in that if you solved B,C,D also.
Yes but there will be a gap between people who submitted A right before the server issues and right after, while in a normal contest its a few second/1 minute off but in this contest is can be over 10 minutes apart.
I'am solve first problem in 1 minute, But the site did not work so I was very late in sending it, It is unfair that unofficially registrars can act on the site's lack of responsiveness while official registrants lose points because of it.
All Had The Same Problem....And There's Ranking for official registrants only
Can someone tell me when CF-Predictor will update the rating for this contest.I am so excited so Its hard for me to wait 12 hours to see my new rating. :p CF-Predictor: https://cf-predictor-frontend.herokuapp.com/contestSelector.jsp
use NBHEXT https://mirror.codeforces.com/blog/entry/21302
you can try chrome extension of cf-predictor, it is working!
Are current #2 and #3 cheating?
http://mirror.codeforces.com/contest/1003/submission/39911751
http://mirror.codeforces.com/contest/1003/submission/39926904
Their solutions for F, other than the template and variable names, look identical.
this often happens, nothing can be done about it.
http://mirror.codeforces.com/contest/1003/submission/39925428 also looks suspiciously similar to the 2 submissions above.
Their solutions to E are also similar (and both got hacked :) ):
http://mirror.codeforces.com/contest/1003/submission/39924725
http://mirror.codeforces.com/contest/1003/submission/39919595
And some guys use other’s resolution to skipped themselves to make themselves unrated.So their rating are increase.
For Problem C , the answer shouldn't vary by more than 1e-6.
I see that some solutions are printing solution till 6th place precision, something like %.6f. This could lead to rounding off at 6th digit after decimal at times, depending upon test cases.
Does anyone have a test case to break this? I tried generating tests, but have no success uptil now :(
U tried generating test cases by taking help of any tool? OR on your own. If u used tool can u plz share
No, I just wrote a program to generate tests for the problem.
I think printing %.6f would be fine and can not be hacked.
See this, for example. If your answer was 1.3333337, it would print 1.333334 as answer, which has difference of 1e-6.
No it actually has difference 1.3333337 — 1.333334 = 0.0000003(3e-7) which is smaller than 1e-6
The difference would be between actual answer (1.333333) and our rounded off answer (1.333334), ie 0.000001
by statement of problem C,
... is the answer given by the jury's solution.
and the jury's solution is printing more than 6 decimal points.
Damn, didn't realize this. Thanks for correcting :)
My pleasure. Actually I thought just like you at first :)
if u .6%,The answer will be rounded.So it is wrong
can anyone plz explain problem B to me its not clear
Thanks
It is really clear.A string S consists of 0 and 1.Number of 0 is a,number of.1 is b.U need to find a S content the situations
add sth. there are x index that s[i]!=s[i+1]
Will the points deduct in case of unsuccessful hacking attempt in this round?
No. Hacking after the contest is over does not change the hacker's rating.
No
Fix a bug in the last 30 seconds, so close :p
What is the main idea of the problem E? I solved A, B, C, D, F and thought for a long time about E
Create a chain with d+1 nodes that has length d. Just repeatedly add new nodes, making sure that each node still has degree <= k and the diameter doesn't increase.
peanutpedo wow ._. you on #1
Thanks, now I solved everything. Code for E
Thanks buddy, ur code made me realise my mistake
I did exactly same, but still, I'm getting WA on 8, I'm unable to get my mistake, help needed http://mirror.codeforces.com/contest/1003/submission/39926411
I solved E using BFS. Here my approach:
First let our base tree is the chain tree which length is equal to d (If d >= n -> answer is No)
Second let try to put more vertices into that base tree, we can observe that we can actually put some 'forest' into these vertices and the maximum height of each vertices is calculatable Let H[u] is the maximum height if we add 1 forest into vertex u, then H[u] should look like this 0,1,2,3,.. d/2,d/2-1,... 0 .
Code : http://mirror.codeforces.com/contest/1003/submission/39923949
nice contest .. problem E is similar to this problem
E had an extra constraint of maximum degree for any vertex. I believe this constraint is (more than) enough to differentiate between the two questions.
that's right .. I was pointing to the general idea which is building a tree with some given diameter
For D, Can someone sketch a proof for why greedy works. First, how can we be sure that greedily removing values would not make it possible to get the sum. How does a local optimum of removing the next maximum power of 2 as much as possible result in a global optimum.
This might be a useful hint. Think about the binary representation of numbers
Yeah that was my first idea. Since the numbers are powers of 2 , they would have only a single bit set in their binary representation. But that didn't get me anywhere substantial.
I meant the binary representation in the queried numbers, this should help you with the first part of your question. For the second part does the fact that 2^i= 2^(i-1)+2^(i-1) help you get further?
Converting decimal to binary is greedy (take the biggest you can until number becomes 0)
Which means that if you use powers of two (numbers you consider taking when forming a binary number) you can use the same greedy process.
Also, you can think of it as coin problem where each number is the divisor of the next, if you have 2i and i coins you would always take a 2i-coin instead of 2 i-coins. Apply that logic recursively until you hit 1. Only issue with this is that there is a limitation on amount of coins you can use, not sure if this affects it
Exactly, without the limitation on the number of coins we can show that it's optimal. But what about this case.
Let's assume our greedy works given no limitations, which it does. Also note that the greedy solution is the only optimal solution, any other arrangement is worse.
Now we can think of a case with limitations.
During our greedy process, we hit a scenario where we need the coin with value 2^a but we don't have the coin.
Now assuming the greedy method is optimal, it is also optimal to use the greedy algorithm to find the solution to 2^a given coin values 2^(a-1) and below (to replace the coin).
This is what our general greedy algorithm does, except we process the whole thing in one go instead of running a separate greedy every time we don't have a coin 2^a. When we are lacking 2^a we greedily replace it with lower value coins, which we already know is optimal.
Let there be two coins, X and Y, such that Y = (2^k) * x. (k >= 1)
If you want to get an amount Z of money given in those coins, it is always optimal to take as many Y coins as you can, before you take any of value X. That is the best you can do, because let's suppose you used only X coins instead of using X and Y. Then, it is clear that you needed at least (2^k) times more coins to make up for the value you could have made using Y, but chose to use only X. So, if you want to have as minimum coins as possible, you need to start from the higher-valued coins, no matter how many of them you have in comparison to the lower-valued ones.
And if you can't form the sum using a X coin, you wouldn't be able to do it with Y either, because using Y means using (2^k) * X. The opposite is also true, only difference is the amount of coins you would need to use to make the sum.
why not, round extended for 10 min
Any tough/tricky cases for E?
What's wrong with this solution for F? 39922956
You got the problem wrong. problem says atleast 2 such segments.
Oh ok, thanks
My first ever hacking attempt against srand(time(0));!
The way I did it: 1) printed time(0) at a certain time
Can u hack again, he submitted in practice mode, by changing some values? xD
Done!
Hack me! 39934835
My solution uses random generation of mod > 1e9 and base for hashing, I think it's not hack, it's true?
I probably couldn't hack it because finding a collision among 1027 possible combinations is extremely unlikely. On Akul's code, there were only 109 possible combinations, so I could find a collision pretty quickly.
Thanks for your reply. What can you recommend in problems with polynomial hashes? Will this solution be safe in other problems?
We can use std::chrono::high_resolution_clock::now() which tick faster than std::time()
F can be solved in O(map * n^2) using hashes. For every length of iterate through interval of this length in increasing order, then using map + hashes store how many intervals you can match, and there is the rightmost one. 39934835
But you must randomize the hash value otherwise your code will be hacked like mine.
What can be causing the RTE in this code
Im losing my mind :D
I think it's a stack over flow because of too many recursions try this test case:
5 1 1 2 4 8 16 10000
answer is -1 your code is giving RTE
Thank you :D
Stack is getting overflowed by repeated calls here
long long add=go(pos);
Try on this :-1 1 1 2
Yes the issue is caused when i call the function giving it a parametre number with only 1 set bit which make an infinite recursive calls .
Is there any way to implement hash so that I won't be hacked?
Hello, I'm new here and I want to know if there is any article describing the whole process of a complete round. Could anyone help me?
Yes editorial will come out probably by tommorow.
Can someone give a nice approach for div2 B problem other than spamming if-else statements? Either way do explain the solution you all submitted, it'll surely help me. The way I thought the solution was as follows: for x such characters in the final string we need (x+1) groups of consecutive 1's and 0's with any number of 1's and 0's in them( obviously there should be more than 1 in each group). But I found the solution difficult to implement. Can someone help me with it?
I also found awkward to implement.
So you need x+1 groups of consecutive 1's and 0's.
The way to do that using minimal amount of digits is just
10101010... or 01010101...
Depending on the constraints one of might fail, but one of them HAS to work.
Not this solution already fits the x constraint, now you need to match it to a and b.
Actually there's an easy way. Insert a bunch of one's next to a prexisting one and zeros next to a preexisting zero.
Like this:
1010101 ---> 11111010101
notice how this doesn't affect the amount of switches now we do the same with zeros
atleast one of our solution will work, we just have to test which one
39905965
Note:
f() creates 10101010 g() creates 01010101
count(v) counts the amount of "01" and "10" in v (should be x)
fits(v) checks if v used less than a and b zeros and ones
First, we implement a sequence which is always flipping like "01010...". Specifically, we set the initial sequence to be "01" if A >= B, or "10" otherwise.
Then, we put the rest of the 0s and 1s into any of the position of 0 or 1, which does not change the flipping number. You can see this implementation 39904229 for details.
I have tried an approach to problem F involving string hashing mod 1e9+7 and then picking intervals to shorten greedily (interval scheduling) but it fails on test case 54.
Now, I changed the modulus to 1824261409 for the hash and it still fails, I think there might be some case I am missing out on, as answer is off by only two. I'm guessing it might have something to do with whitespace, but codeforce does not let me look at the full case. Can anybody pinpoint what's causing the anomaly?
39940552
just use a
map<string, int>
and change everything to intsAlternatively you can use double hash or even triple hash, but that is probably too much time to code and too error-prone.
That test case is actually one I used to hack, it's 299 'a's and one string with 99000 'a's.(that test case was originally designed to possible TLE something, but i saw a solution give a negative answer on it and hacked it with that). If you want a smaller test case, then try this:
3
aa aa a
Your answer: 4
Expected answer: 5
Your solution treats 'a's as 0s, meaning that it recognizes "aa aa", "aa", "a", "aa a" and "aa aa a" as 0. To fix that, you need to treat 'a's as at least one, meaning you need to add one to your base and the letter. 39946086
Thank you, it is very helpful.
Getting the same answer for the 54th test case , any advice for me :D
http://mirror.codeforces.com/contest/1003/submission/39954969
Resolved :D Thanks for the test case description
i am a beginner just wanted to ask when will the final results be out for this contest??
I don't understand why two same solution one in Python and another in Java give different verdicts.
The one in Java passes while the Python one gives TLE
Simple: because not all programming languages are equally fast.
P.S. if you're using python, try submitting with PyPy interpreter. It's optimized for speed.
I think that we shouldn't have been able to hack F, because there is the hash solution for which there always theoretically exists a countertest. I might be a little biased here, because it happened with my solution: 39926278, but it also happened to more than half of the solutions of F.
That's why sometimes
srand((long long)new char)
is needed. xDForgot about it. Thanks for reminding me. Still not an elegant solution though...
Where's editorial ?
Can someone explain how to solve F? Or just give some hints?
hey for E, my 39924761 hacked, but i show the hacking test, that was 5 4 1, http://mirror.codeforces.com/contest/1003/hacks/465215/test, my answer is "NO", it is correct answer i think, why my solution was hacked? sorry my poor english. vovuh
it depends on exit(1), exit code 1 means runtime error on codeforces, I regret what I dont know about it. I changed my code exit(0) get AC
Same codes with just reformatting again from Mo2men and Molo5ya.
39914320 39910896
MikeMirzayanov vovuh
is there going to be an editorial for this round?
Why so much people used hashing solutions on F when a simple string matching algorithm like KMP works just fine?
It's easy to code . At least for me it's easier .
But it's not very reliable. I have bad luck when choosing the big prime numbers for hashing, and I say "luck" because I don't quite understand how to choose them, I just pick the most famous ones around, and yet most of them have complex counter-cases!
Well I am afraid of being hacked . So I choose the prime randomly . And I got wa . I got ac after I use a certain one . I don't know why srand and rand affect so much . :(
Why so much people used hashing or KMP solutions on F when http://mirror.codeforces.com/contest/1003/submission/39912717 works just fine?
I think that's a better question
In the graph of problem E how do I calculate the maximum number of edges?
What do you mean? Since the output is a tree with n nodes, it's always going to have n - 1 edges — no more, no less. Did you mean something else?
I guess, to answer your question, the maximum number of edges is always going to be n - 1.
Oh yea I just got confused ty
self-delete
Hey at least DQ these guys first http://mirror.codeforces.com/blog/entry/60377?#comment-442301 from official standings before DQing me
self-delete