|
|
help pls окей это было связано с тем как я неверно пытался сделать корнем узел тани I also have WA10/ Help Someone! I m too :\ 9 8 2 0 4 3 0 0 5 6 0 0 0 0 9 0 7 0 1 correct answer 4 some Test Please !!! 9 8 2 0 4 3 0 0 5 6 0 0 0 0 9 0 7 0 1 correct answer 4 I accepted 0.39(5kb). I use template veckor class(C++) to store list of employees. But I don't know how make my program faster :( Edited by author 30.09.2008 14:40 Edited by author 30.09.2008 14:51 Don't use vectors - these are VERY slow structures (as, by the way, all STL components). Rewrite with usual arrays - and, I think, speed of your code will increase several times... i use vector too, i think if i got use array memory limit have exceeded. Don't use vectors - these are VERY slow structures (as, by the way, all STL components). Rewrite with usual arrays - and, I think, speed of your code will increase several times... This statement is just wrong. In which part? For any STL component I can write much faster analog. Well, I was refering only to vectors. Of course you can make sets/maps/other stuff faster. But the underlying structure of a vector is the same array. E.g. vector<int> is just a {array pointer, size, reserved mem}. I've heard this myth about vectors being slow several times, that's exactly why I've done some real testing of it - absolutely no difference, especially if you give the size beforehand (which you have to do in case of arrays). Actually, if you use an iterator to iterate through your vector, it can sometimes actually be faster for different reasons. The only difference may come from using multidimensional (i.e. nested) vectors - in that case, indeed, there can be some performance differences, but still, saying "VERY slow structures" is an extreme exaggeration... remember, you said "increase several times" :). Edited by author 02.04.2011 02:12 i accepted :D Congratulations! I accepted too : ) It's easy task Edited by author 11.05.2013 17:15 Edited by author 11.05.2013 17:15 "...Она сразу же позвонила своей начальнице, затем своей подруге Лене, находящейся у неё в подчинении, потом Кате и Маше...". In my solution she can call friends, and then her boss. And solution, when she at first call the boss and then friends, get WA4. What the 17 test? why WA? armenia1993@mail.ru int charact(int v) { used[v] = true; vector<int> dp; for (int i=0; i<g[v].size(); ++i) { int to = g[v][i]; if (!used[to]) dp.push_back(charact(to)); } if (dp.size() == 0) return 0; sort(dp.begin(), dp.end()); for (int i=dp.size(); i>0;--i) dp[i-1] += dp.size() - i + 1; return *max_element(dp.begin(), dp.end()); } If you enumerate vertices from 0, be sure that you decrease root's number before calling DFS. My AC (accepted) program (numbers of submits: 3740606 or 2776983) has BIG Time Limit at home on this test: 100000 2 3 [...] 99999 100000 0 0 [... number "0" repeatedly 99999 times] 0 1 This test may be got by this simple program (on Pascal): var I, N: Longint; begin N := 100000; Writeln(N); for I := 2 to N do Write(I, ' '); Writeln('0'); for I := 2 to N do Writeln('0'); Write('1'); end. Please, add this test and its analogs to test base. Edited by author 22.08.2011 13:52 Your test is added. 26 authors lost AC after rejudge. Thank you! no. This is not very well formulated. First, the problem statement says "She called her boss immediately, then her friend...", implying that she must call her boss first, even if that's not optimal. What about other employees? Must they also call their bosses before any subordinates? i use O(nlogn) and got AC, if you use O(N) for this problem, plz tell your algo to me. sorry for my poor english. You can do all you want but never, never use dynamic structures!!!! MLE=16M I think, it's not correct. My Java solution gets MLE20, but the same solution, used C++ gets AC with 8M of memory. The method is something like DP + greedy... yeah! 0.078s 2406 KB Is this greedy right? : 1. Make Tanya a root. 2. Every employee call to his children in descending order of c[i], where c[i] is the number of descendants of the ith vertex. I got WA on test 10. Edited by author 26.10.2006 17:17 Your idea about making Tanya a root is very good. I've used it and got AC. (Thank you! :-)) But second point of your idea is definitely wrong. Analyse the following test and you'll get your AC: 14 2 9 0 3 4 0 5 6 0 7 8 0 0 0 0 0 10 0 11 0 12 0 13 0 14 0 0 1 Answer 6, My Algo give. I use Greedy Heap + BFS. WA10. First idea - Tanya Root, second Idea - when we count i- root time we use best times of his sons in the descending order. I think it correct but mistake&! some tests please!!!!!!!!! I think my algo is right(DP) but I have WA#4. Anyone gives me some tests or hint. P.S. Sorry my English. Is Tanya calling her Boss at first or not??? I do the best I can to avoid this time limit --> but I can't Tell me what shall I do ???? |
|
|