|
|
Common BoardIs there some constructive approach? I solved it with some tricky bruteforce with optimizations find out how to solve the problem for n <= 68. for bigger n just do n = (n - 35) % 34 + 35 and solve the problem for this n. i think the memory limit should be higher Отсутствует язык отправки C# this is a very cool task, it requires a little out-of-the-box thinking, I really liked it Input: 4 2 1 1 5 3 7 -1 4 7 1 2 3 4 Correct output: NO One of the reasons of "WA" might be that your solution incorrectly determines whether two segments intersect or not. Edited by author 11.04.2020 15:09 Maybe you output multiple answers. Reason: after output a correct answer,the program should be exit,but you may not do that. (I'm sorry for my bad English) Input 2 2 .. .. Output 1 Input 12 12 ************ ************ ************ ******..**** ******..**** ************ ************ ************ ************ ************ ************ ************ Output 1 Input 2 4 .... **** Output 0 Input 4 2 .* .* .* .* Output 0 Input 2 5 ..*.. ..*.. Output 0 Input 5 2 .. .. ** .. .. Output 0 Input 12 12 ............ ............ ............ ............ ............ ............ ............ ............ ............ ............ ............ ...........* Output 0 Input 6 6 ...... ...... ..**.. ..**.. ...... ...... Output 14 Input 6 6 ...... ...... ...... ...... ...... ...... Output 1072 Input 12 12 ............ ............ ............ ............ ............ ............ ............ ............ ............ ............ ............ ............ Output 1076226888605605706 input: 10 3 10 2 4 8 9 9 10 11 18 22 29 output: 8 0 1 0 3 0 3 1 8 1 8 3 9 8 9 9 17 17 21 21 28 input: 10 3 50 70 113 132 135 135 136 140 140 140 144 194 231 242 275 287 337 359 362 381 391 418 432 436 478 530 541 551 553 560 560 567 575 594 631 634 646 649 676 702 728 738 771 824 858 889 907 922 933 976 987 output: 75 60 69 103 112 125 131 125 131 125 134 130 134 130 139 130 139 131 139 134 143 184 193 221 230 232 241 265 274 277 286 327 336 352 358 352 358 371 380 381 390 408 417 426 431 426 431 468 477 520 529 531 540 543 550 543 552 550 552 550 552 565 566 565 566 584 593 624 630 624 630 639 645 639 645 666 675 692 701 718 727 728 737 761 770 814 823 848 857 879 888 897 906 912 921 923 932 966 975 977 986 Is there a way to just get the first character of the type of experiment? (Like, if it is "hungry" just receive the "h" and ignore the rest) Why can't you use string and only judge the string[0]? Input Values is not in a range [3, 9] Input Values is not in a range [3, 9] Some data which will help understand problem and test it! Test: 2 40 223 Answer: 3 aromatize 1 dearomatize 1 take 2 1 2 Test: 3 50 55 158 Answer: 3 aromatize 2 dearomatize 1 take 3 1 2 3 Test: 4 100 512 128 146 Answer: 3 aromatize 1 dearomatize 2 take 4 1 2 3 4 Test: 2 100 135 Answer: IMPOSSIBLE Test: 2 400 31 Answer: IMPOSSIBLE Test: 2 100 171 Answer: IMOSSIBLE Thank you very much! I got AC from first submit after my code finally work on all your test cases. 3-edge connected components of graph. A Simple 3-Edge Connected Component Algorithm by Yung H. Tsin. But I self do not found this article :) I have a stupid idea to solve this problem: first ,dfs a tree, then for each node compute the hash_value of edge set which cover this node.. for each query a,b if for every node on the path of (a,b) the set of edge cover by this node is not equal to any node outside the path of (a,b) and times of edge segments covered the path >=2 then result is Yes,otherwise it is no.. I'll try to use president tree to implement this idea... hope there is nothing wrong.. Edited by author 05.12.2016 14:35 Edited by author 05.12.2016 14:35 WA on test # 18,any one help?? AC 0.421s O(n*log(n)^2) its log(n)^2 because I use heavy_light decomposion+segment_tree ccz181078 has give a random solution to the sub problem of this problem:: give a tree with n node,n<=50000 for every edege there is a color 1<=c<=50000, give q<=50000 queries ,for each query give two node a,b judge for every color on path a-->b this color appear only on the path a--->b ,not outside path a--->b. sol :for every edge gives a random 32 bit number, so that for every col xor of edge with this color is zero.. for each query just judge if xor of random number on this path is zero. if it is ,answer is Yes, otherwise it is No You're wrong. The answer may be "Yes" but nodes not in one 3-edge connected component Sorry, I'm stupid, it works this test may help you 5 6 1 2 1 3 1 4 2 5 3 5 4 5 10 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5 ans: No No No Yes No No No No No No Input: 4 000000001111111111111111 8 4 5 6 7 8 15 16 17 17 18 19 20 21 22 23 24 Example output: 1 2 9 10 11 12 3 8 15 16 17 18 4 5 13 14 19 20 6 7 21 22 23 24 Input: 4 111010011110110110111100 15 1 2 2 3 3 4 5 6 8 9 9 10 11 12 13 14 14 15 16 17 19 20 20 21 21 22 22 23 23 24 Example output: 1 2 3 4 11 12 5 6 8 9 10 18 7 13 14 15 16 17 19 20 21 22 23 24 Input: 4 101101111001111001001111 14 1 2 3 4 4 5 7 8 8 9 9 10 10 11 13 14 15 16 16 17 19 20 21 22 22 23 23 24 Example output: 1 2 3 4 5 12 6 13 14 15 16 17 7 8 9 10 11 18 19 20 21 22 23 24 Input: 3 111111111111000000 9 1 2 1 13 3 4 5 6 6 7 8 15 10 16 11 17 12 18 Example output: 1 2 8 9 13 15 3 4 10 11 16 17 5 6 7 12 14 18 My program was skipping only empty lines, and I was getting WA7. When I started skipping lines consisting only of spaces, I got AC. I run 2 bfs. The first bfs starting from node S (that is caravan's distances) and the second starting from node R (that's distances from robbers). Then i recover route for caravan and on each step backward i choose node with maximum robber distance. Minimum of robber distance on the caravans path is the answer. What's wrong? It's because you can't greedily choose the node with the maximum robber distance. One of the other paths might contain a node with a smaller node distance somewhere further along. One such graph is here (this one is rather long, you probably just want to try to generate a graph that violates your greedy strategy yourself): 15 20 1 2 2 4 4 6 6 8 1 3 3 5 5 7 7 6 4 5 2 3 7 8 7 9 9 10 10 11 11 12 12 6 11 14 14 13 13 15 15 3 1 8 11 One strategy that works is to BFS backwards from the finishing vertex, and along each path you maintain the minimum robber distance. When two (or more) paths merge on some vertex, you consider the minimum of this path to be the maximum of the minimums of the two paths. Otrebus, thank you for strategy ! what will be the ans of this case, could you tell me please??? 3? i am also getting 3 for this case but wrong answer on test case #2 .. That's an intersesting strategy. Now I have to find out how do you know when some paths emerge on some vertex Input: 2 .-.... |1|... ...... ....-. |*..2| .-..-. Output: Draw Input: 5 ............... .1||....||..... ............... ............... ..||..|.||.||.. ............... ............... ..||.||.||.||.. ............... ............... ..||.||*|..||.. ............... ............... .....||....||2. ............... Output: Win 33 M2 Input: 5 ............... .1||....||..... ............... ............... ..||..|.||.||.. ............... ............... ..||.||.||.||.. ............... ............... ..||.||.|..||.. ............... ............... .....||*...||2. ............... Output: Draw Input: 6 .-..-..-..-..-..-. |1...............| .................. .................. |................| .................. .................. |......*.........| .................. .................. |................| .................. .................. |................| .................. .................. |...............2| .-..-..-..-..-..-. Output: Win 15 M2 (or Win 15 M6, does not matter) Input: 6 .-..-..-..-..-..-. |1...............| .................. .................. |................| .................. .................. |.........*......| .................. .................. |................| .................. .................. |................| .................. .................. |...............2| .-..-..-..-..-..-. Output: Draw Input: 6 .-..-.....-..-..-. |1...............| .................. .................. |................| .................. .......-.......... ......|*.........| .................. .................. |................| .................. .................. |................| .................. .................. |...............2| .-..-..-..-..-..-. Output: Lose 1 S5 Edited by author 02.04.2025 17:51 I've used dp solution accepted. But I think my approach is a bit awful. So, I'd like to see some nice dp approaches. Thank you! Email: shiyuyang032421@gmail.com |
|
|