Discussion of Problem 1325. DirtPage 2 THIS TEST 6 5 1 3 6 3 11112 22221 11112 22212 21112 22222 ANS:7 1 I changed my INF to 1e18 and got AC My old C++ solution got AC with optimized Dijkstra, O(v*log(v)), where v = m*n. The timing was 0,406 sec. Evidently, with Python (2.7, 3.4) I got TLE with the same solution. On my machine 500*500 case runs for 4.5 seconds. Then I realized O(m*n) solution and optimized input as much as possible (Python). It still gives TLE16, on my machine - runs for 2.3 seconds. Then I run code under PyPy (5.4.1, Python2.7 compatible) and on my machine it runs for 0.383 seconds only. I hope it would AC if PyPy is able to be selected as a programming language. Please add PyPy! Thanks Can anybody that had WA7 give me some hints? Thanks Maybe that's because you didn't calculate the right shortest-path with the least boots changed(that is, your first number of the output is wrong, but the other one is right). I've got WA7 because I used only one bfs to calculate both values. 2 bfs should be used. (BTW, some of my classmates said only one bfs could also work??? I'm not sure about this. Gimme some data, please Example test: 8 8 1 1 8 8 22122111 22121122 22212211 11111222 11122211 22212222 22112121 11122221 Distance table of my TLE21 solution: 0 1 2 4 4 5 6 7 1 1 2 3 4 5 6 7 2 2 2 3 4 5 6 7 3 3 3 3 4 5 6 7 4 4 4 7 6 6 6 7 10 9 8 5 7 7 7 8 10 9 6 6 8 8 8 8 8 7 7 9 9 9 9 9 Distance table of my WA25 solution: 0 1 2 4 4 5 6 7 1 1 2 3 4 5 6 7 2 2 2 3 4 5 6 7 3 3 3 3 4 5 6 7 4 4 4 7 6 6 6 7 10 9 8 7 7 7 7 8 10 9 8 8 8 8 8 8 10 9 9 9 9 9 9 9 Gotta investigate it yet... But still AC in 0.171s :D even with super many optimizations (like not reading matrix, thus reading when needed; putting x's and y's in one integer and so on) come on :D slower than 2 BFS and even slower than dijkstra : \\ I suspect that I heavily use deque is the main reason. How can I replace deque with some other decent data structure that will let me quickly add and remove items? list<> in STL is dumbly slow for little objects ( dafaq who would have thought ?! ) point is equal. e.g. 3 3 1 1 1 1 111 111 111 answer:1 0 Time limit decreased from 1 second to 0.5 second (it corresponds better to the original TL in 2004). The problem was rejudged. Many old solutions with TLE verdict got AC, while all new solutions working in time from 0.5 to 1 second got TLE. when trying to update from (ux,uy) to (vx,vy) i was checking if (vx,vy) was already popped from priority_queue. this got me wa 22 many times. later, just out of frustation i removed the check and let (vx,vy) be updated even after it was once popped. and u know what, mysteriously got AC. of course, there has to be some logical explanation behind that. please explain anyone? Thanks in advance. I followed by your advice, and also suprised! run_id = 2970301 test: 10 10 1 1 10 10 1211211212 2111221212 2221001111 1112112012 2112102112 2111200222 1112021212 2222011211 2112222222 2012122122 right_answer: 12 1 my program produces answer 14 1 I spent about an hour till i figured out that: If it is impossible to get from the computer to the refrigerator, you should output 0 0. !!!! Thank u so much! How should I forget this! i got wa on 16 please give me test# 16, i don't know where my mistake: size of heap and arrays are enough. I get WA 16 too. =) I don't know your mistake, but my mistake is ... I use "short". Never use "short"! Use "long" or "__int64". =) Max. count of "boots changes" == 500*500 > 32000. It's funny. =) Page 1 Strange.. in 1254 a got AC with 3.656, but in 1325 with 0.625.. maybe you use another method. i used heap, and pop element with less distantion. BTW i suppose, that distantion between clear square and dirty is very big, 200000 is enough. And this path is solution of problem. Edited by author 11.01.2009 18:47 strange.. maybe you have mistake in solution. btw i use int64 in heap, with longint i have WA. I've solved this problem in 0.9 sec, just 0.1 sec berofe TL. But I see that there could be much more efficient solution. Please mail me at wooden@bk.ru with a cpp source, it's very interesting for me. Help, me. Pleassse... ....... Now I AC 0.203s, but 4422 KB This test help me: 5 7 1 1 3 5 1011111 1211101 1222221 1020101 1111110 5 1 Edited by author 19.04.2006 01:21 Edited by author 19.04.2006 21:02 did anyone make the same mistake? what's that? o,i see now. Can you tell me?I got the WA on #16,too.Thank you. Yes, I have the same problem... I had WA#16 because of the size of the queue. Me too... When I tryed to change array size, I've got TLE#16, then I do a small optimization, and I've got TLE#16 again. I think used algo is incorrect. Use dijkstra+heap (easy to write) or double BFS (fast speed). ----------------------------- Sorry for bad English Edited by author 16.03.2007 17:56 I used double BFS and got AC) I have written 2 programs and both get WA19 It is very strange, I am already tired to write programs to this problem. first 2*BFS secondar Dijkvasta+Heap both got Wa19 i not understand why. Somebody help me? hi I don't understand in english. hwo can explain this question in Azeri or Turkish or in english but with sample sentenceses you just need to do 2 BFS Edited by author 22.03.2010 02:04 Edited by author 22.03.2010 02:04 ????????????????????????? n=3 and m=7 This is an example test. Please admins correct it ???????????????????????????
Edited by author 07.10.2005 16:30 У меня программа тоже находит такой путь. И я просто к ответу прибавляю всегда 1 Разве путь не : { I also find the program that way. And I just added to the answer is always 1 Is not the way: } 2 1 3 2 2 3 2 4 1 5 2 6 3 7 А пример: {Simple} 2 2 1 1 1 2 11 00 My program returns: 2 0 Right ? Accepted 0.531 Edited by author 03.01.2012 22:24 |
|