fcspartakm's blog

By fcspartakm, history, 19 months ago, translation, ,

•
• +49
•

 » 19 months ago, # |   +4 What's the complexity of F?
•  » » 19 months ago, # ^ |   0 n^2lgn,I think
•  » » 19 months ago, # ^ |   0 O(n^2logn + qlogn)
•  » » » 19 months ago, # ^ |   +2 Won't it be TLE?I'm afraid if it'll be TLE and I optimized it to O(nm+q).
•  » » » » 19 months ago, # ^ |   +3 Wow, How could you answer each question in O(1) ?
•  » » » » » 19 months ago, # ^ |   0 DFS on the tree and maintain the DFS stack. It's off-line.
•  » » » » 19 months ago, # ^ |   0 My O(n^2logn + qlogn) solution passes in 700ms.
•  » » » » » 19 months ago, # ^ |   0 So fast...
•  » » » » 19 months ago, # ^ |   0 it won't throw TLE in java if u are conscious abt what u r doing
•  » » » » 15 months ago, # ^ |   0 My submission with O(nm+q) need 514ms solution
 » 19 months ago, # |   0 In Problem E, why is it necessary to sort items, or I will get the wrong answer?
•  » » 19 months ago, # ^ | ← Rev. 3 →   +14 If we implement only a simple knapsack for the problem then we wont get the optimum answer.Check this case22 4 1001 2 100answer is 200 we can save object 2 and then save object 1.But we lose the number of the object after sorting.How can we get back the order??We can store the indices in a structure format or map them before sorting.I used structures because it was comfortable for me.My structure had t,d,p and then num(where t is time needed to save,d is time after which the object cant be saved,p is the value and num is the initial position of the object before sorting).Hope this helps.Let me know if you have any difficulty.
•  » » » 19 months ago, # ^ | ← Rev. 2 →   +3 Thanks. I just wonder why I must sort these items. And now I see it's because selecting these items in different items will get diffrent answers, but normal 01 knapsack won't.
•  » » 19 months ago, # ^ | ← Rev. 2 →   +3 I've just got an insight about problem E: Fire. I believe that its plot is perfectly described in the scene youtube: "Quicksilver saving mutants from explosion in Xavier's school basement" // "X-Men: Apocalypse". So my editorial is: imagine that d[i] + 1 is the time moment when explosion hits the i-th creature and try to be as good as Quicksilver even though his ways of always getting Σ p[i] did a fresh change to the problem overall perspective)))Here is the screenshots for Chinese users (0.5 MB)
 » 19 months ago, # | ← Rev. 3 →   0 My solution is literally O(nm + q) but it is distincly slower than other solutions
 » 19 months ago, # |   0 In problem E why does sorting elements based on parameter d gives us the correct solution? I cannot understand the logic behind it from the tutorial.
•  » » 19 months ago, # ^ |   +2 basically its about the order of choosing items . its better to choose the items first that will be burned sooner right ? because if you dont choose them fast (if its better to choose them) you probably cant choose them ever
 » 19 months ago, # |   0 30745421 whats wrong with my code of D...I followed this editorial did I missed something..
•  » » 19 months ago, # ^ |   +1
•  » » » 19 months ago, # ^ |   0 Thanks... I didn't think of this silly mistake
 » 19 months ago, # | ← Rev. 2 →   -19 .
 » 19 months ago, # | ← Rev. 2 →   0 Why my program not work in task B. In my computer its working good! http://codeforces.com/contest/864/submission/30750759
•  » » 19 months ago, # ^ |   0 Console.ReadLine(); string a=Console.ReadLine();
•  » » » 19 months ago, # ^ |   0 And what??
•  » » » » 19 months ago, # ^ |   0 // read n Console.ReadLine(); // read string s string a=Console.ReadLine(); 
 » 19 months ago, # |   0 My solution for E is not printing right items. Can anyone help me? My submission is LINK
•  » » 19 months ago, # ^ | ← Rev. 2 →   0 I have the same error in my code. The issue with the order can be fixed through sorting. I assume you are sorting just based on the 'd' values. If so, then when 'd' is equal, the item with lower 't' value should come first. This solved the order disparity for me...however there is also a problem that while printing one item is skipped (I have the same problem too)...I have so far no idea why this happens.Edit: The order might not be the real issue here...the answer is probably still valid. The main issue is the fact that one item is skipped while printing.
•  » » » 19 months ago, # ^ |   0 Why it is printing one item less when it is giving correct value ? I am not able to understand.
•  » » » » 19 months ago, # ^ |   +1 I rewrote my solution to print the value of the answer from the constructed solution and it turns out it gives the same answer. This shouldn't be the case...if our constructed solution were wrong we should get a smaller value...
•  » » » » » 19 months ago, # ^ |   0 Solution is not wrong. But backtracking is wrong.
 » 19 months ago, # |   0 Cana anyone please explain the solution idea of problem 864F — Cities Excursions. I have read the editorial but I can't catch the idea :( .
•  » » 19 months ago, # ^ | ← Rev. 2 →   0 I couldn't catch the last two paras of the editorial, but here's what I understood-Suppose we are at sj node currently. Now, consider all nodes connected to it with an edge, and let u be the lexicographically minimum among them, from which we can reach tj via dfs/bfs. Obviously it will be optimal to pick u. Because, from u we can still reach tj node from u-maybe at an infinite time(ie, never actually reach it). That is, we greedily select the next node. This gives us an n*q solution, what the last two paras did is to optimize this part.
 » 19 months ago, # |   0 "The lexicographically minimal path from the vertex sj to the vertex tj is equal to the inverted path from tj to sj in this tree." Please elaborate. Problem F.
 » 19 months ago, # | ← Rev. 2 →   0 In Problem E, the editorial wants dp[i+1][j+t] to be found as the maximum of itself and some other number. Is this a typo? It doesn't make sense to find a value with itself.And it does this in the second line, as well
•  » » 19 months ago, # ^ | ← Rev. 2 →   +1 I was also confused at first, but it makes sense if you think of all the values of dp as initially 0. So after initialization, it is just about upgrading the values of dp through those seemingly recursive relations.
 » 19 months ago, # |   0 Can someone please give a more detailed explanation regarding F. I am unable to understand it from the tutorial. It would be really nice, if you could explain the implementation details as well.
 » 19 months ago, # |   0 And what is binary climb?
•  » » 19 months ago, # ^ |   0 See the section where LCA is done in
 » 19 months ago, # | ← Rev. 2 →   0 In Problem A 4 1 2 3 4 what answer should come with this input .My answer is YES1 2 3 4 but its wrong
•  » » 19 months ago, # ^ |   0 I think NO is true because it consists of 4 different number, and there are just 2 girls.
•  » » » 19 months ago, # ^ |   0 thanks
•  » » » 19 months ago, # ^ |   0 Petya and Vasya — I think they are boys..)
 » 19 months ago, # |   0 Can Somebody help me with Problem F,Test 13? I use Tarjan to check if there is a cycle,while always get WA on Test 13 I see many people get the same problem with me , how to correct it?
•  » » 18 months ago, # ^ |   0 Try out these cases, they were useful to debug my idea:4 5 1 1 2 1 3 2 4 4 2 3 4 1 3 1 Ans = 14 5 1 1 2 1 3 2 4 3 4 4 2 1 3 1 Ans = 1
 » 19 months ago, # |   0 In problem 864E-Fire, Consider this case : 3 20 21 20 3 6 1 4 8 2 Now if we sort the d parameter, then we select the 2nd element first because its d value is the least(6) and then the 3rd element, whose d value is 8. But using this method, we ignore the 1st case, where if we only save the 1st item, then we will get the maximum value of saved items, which will be 20. So can anyone please explain how we can solve this just by sorting the d parameter?
•  » » 18 months ago, # ^ |   0 you may got the answer 20 in dp[3][20], because dp[3][20] = dp[2][0]+20 = dp[1][0]+20 = 20, and why we can simply solve this by sorting d was explained at before
 » 16 months ago, # |   0 I was looking at problem A and made myself another problem. Suppose we have n different numbers and I have to select all numbers that has that number (at any index). Is this problem possible to solve and if yes how?Example: 4 21 1 34 3 answer should be: YES 1 3. I select all numbers containing 1 and all containing 3 in different groups.