|
|
i spent a lot of time on this task and i am very happy that i did it, i recommend that you also try to solve it yourself to improve your optimization skills Я просто накидал кучу каких-то непонятных оптимизаций, и оно почему-то зашло For WA #17 IN: 6 8 13 80 17 58 92 67 57 88 96 28 65 22 OUT: 6 ..... TLE #10 IN: 30 1 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 ...... 0 30 Edited by author 12.06.2011 15:01 The simplest search takes 0.4s, to finish in 0.015s cut the search once it is obvious that it cannot succeed, e.g., for each city index C calculate the set of cities that must be already covered once you decided what cities before C will be targeted. In the above TLE#10 example, if you continue search starting from 3, then 1 must be already covered, that is 1 or 2 must be targeted. BTW, bitset<N> is slightly slower than equivalent bit manipulations with int32_t, probably, because bitset uses uint64_t. I solved this problem( 0.015 sec) but My algo is heuristic. Why this problem is geometric? Or how can we use geometry in this task to reduce the search? I think there might be as well a mistake in tags. To me, this problem reminds of http://acm.timus.ru/problem.aspx?space=1&num=1326 with minor differences: 1) cities = bottle taps 2) N <= 30 instead of N <= 20; 3) city's "group" is a list of cities hit when bombing this one. I tried greedy approach during the contest, but got failed. Idea was in bombing the city (even if it has been already destroyed) with the most number of remained cities in a radius. But WA#14. Please, would you share any AC idea? just bruteforce My bruteforce dies with TL :( There should be some optimizations. Edited by author 22.03.2011 12:31 Finally AC. Yes brootforce rules here. But it's a little BIT tricky brootforce. Edited by author 22.03.2011 12:39 Idea: Graph, Minimal inner stable subset, algo of Bron - Kerboach(effective brute force) oh..(my God!?) Idea: Graph, Minimal dominating set of vertices, problem of set covering, simplest brute force stack searching with table of covering reducing, easy AC By the way! To admin!. It is interesting to make competiton on one problem only(which is NP): minimal covering collection of sets. This algo is very helpfull in practice. Edited by author 25.03.2011 11:10 Could you explain the meaning of this "table of covering reducing"& I've never heard about it. My BF gives TL 10 :( By the way, isn't the problem #1739 - Faryuks based on minimal covering collection of sets algo, as you want? "table of covering reducing"- my term(auto trans. is used) Classical algo for minimal covering had good success in this problem and under emotion I wrote that helping. Again: we have NP problem but can to speed up. So, in stack data we add matrix of covering for example as 1 0 1 0 0 1 1 1 0 1 1 1 This means that 4 points(columns) are covered by 3 sets(rows). First point is covered by only 1-th row and we must use Set-1 as obligatory. Thus, the search tree hasn't branching in this-time vertex and we create only one child vertex with reduced matrix: 1 1 1 1 because 1,3 points are covered by obligated row 1. Finally: when we make choice for some set in search tree we transfer in child vertex reduced matrix. P.S. I had expirience in this algo from boolean design(all practice problem are NP). I did really stupid brute with simple speed up, like bit mask for graph and degree sorting for each connected component. AC with 0.3 seconds. to: svr could you send me your solution of this problem, please? :D my mail: night10101@yahoo.com Edited by author 30.10.2012 22:29 SVR, please, can you tell me, how can you use idea of Bron - Kerboach algorithm and inner stable subset into this problem? It's really interesting and surprising for me. How to use Bron - Kerboach for finding Minimal Dominating Set? Or how to reinterpret problem for searching inner stable subset? answer is minimal covering + independ vertexes. Am I rigth? I count the neighboring cities, which will destroy the explosion in the ith city. After that, output the citys which have not yet destroyed and with the largest number of neighbors (which fall under the explosion) until I have destroyed everything. Simple BF but WA8 :( Can anyone help me? Maybe i forgot about any special case? Edited by author 25.03.2011 19:56 In the 8th test it is optimal to bomb city which is already destroyed. During the contest I kept getting WA because of that... Thank you! Now I count the number of alive near-citys on each step for each city hasn't been bombing. And gets WA13 :) This test Helps on WA8 :) 6 2 1 1 2 2 2 4 4 0 4 2 5 3 Answer: 2 2 5 If you get this one Edited by author 22.04.2011 23:30 Try this: 8 10 0 10 0 20 0 30 0 40 0 50 10 30 30 40 80 50 Correct answer is 5 3 2 4 7 8 |
|
|