Common BoardAny hint for WA3? 'm stuck with WA5 :( 'm stuck with WA5 :( Don't forget rotate clockwise and anticlockwise at one step! Yes, rotating just 90 degrees in either directions takes one step. What's the trick here? This test helped me to overcome WA3: 4 2 2 3 3 1 4 1 3 2 3 1 1 4 4 2 The answer is 4. Because collect '4' needs 5 steps, but collect '1' needs only 4 steps. My answer is 4. I made a classic backtracking which gets WA3 and also a Greedy who also gets WA3, which works as follows: - assume the square is solved with 1 in the upper left corner, compute the orientation of each of the layers (0 if ok, 1 or 3 if with a rotation we reach 1 in the corner, 2 if with 2 rotations). - now try to rotate the layers to achieve the color i in the upper left corner - so for each layer determine the minimal nr. of steps to move the color i from layer j in its correct position - compute the minimal number of moves to reach the solution with color i in upper-left - print the minimum out of those values Edited by author 25.10.2011 15:22 I figured out the test #3, it has T[0][0] = 2, T[0][1] = T[1][0] = 1, T[1][1] = 3, "if (...) while(1);" did the trick. So the whole table I assume is 2 1 2 4 1 3 1 2 3 4 2 4 1 3 4 3 My program outputs 2 as a minimum (rotate layer 4 clockwise with 90, rotate layer 3 anti-clockwise with 90), resulting a solved cube with 1 in its left corner. The judge answer is 3, but I don't understand why. Am I missing something? Edited by author 26.10.2011 00:04 AC at last! The problem in my solution was that I assumed always that the colors were 1-red, 2-yellow, 3-green, 4-blue, but they say that one number is one color so they could be permuted in any way. Edited by author 27.10.2011 01:55 My AC program gives 2 as the answer for: 2 1 2 4 1 3 1 2 3 4 2 4 1 3 4 3 My AC program gives 2 as the answer for: 2 1 2 4 1 3 1 2 3 4 2 4 1 3 4 3 Strange. Mine gives 3. (Also AC). Edited by author 29.06.2012 20:52My AC program gives 2 as the answer for: 2 1 2 4 1 3 1 2 3 4 2 4 1 3 4 3 Strange. Mine gives 3. (Also AC). Edited by author 29.06.2012 20:52It's obvious that the answer is 2. Bad tests :) Mine gives 2 and I got AC for this input: 2 1 2 4 1 3 1 2 3 4 2 4 1 3 4 3 Edited by author 02.07.2019 19:33 But this test incorrect, because always colours order 1-2-3-4 IN this tet 1-2-4-3. My AC solution also gives 3. This test helped me to overcome WA3: 4 2 2 3 3 1 4 1 3 2 3 1 1 4 4 2 The answer is 4. Because collect '4' needs 5 steps, but collect '1' needs only 4 steps. You're wrong. The answer is equal for every colour cause you cann't collect only one colour but all the colours together. To collect '4' you must turn left inner square and turn right two outer squares each for 1 time. So we have 3 steps in sum. P. S. Sorry for bad english ( Edited by author 29.08.2012 23:31 Edited by author 29.08.2012 23:31 Edited by author 29.08.2012 23:33If we turn squares as you said we will get this situation: 4 3 3 3 4 4 3 2 4 1 2 2 1 1 1 2 If we turn squares as you said we will get this situation: 4 3 3 3 4 4 3 2 4 1 2 2 1 1 1 2 Yes, you're right ))) We need one more step - turn right the square which includes element table[3][1]. So, the answer is 4. ac is reached just using 4 elements in inputs. This problem can be solved without random exirsices :) I have got AC just by writing triads in order(without spaces): aaa aab aac aad... aba abb abc abd... zzz. I did it recursivly. And then you must repeat this sequence until number of characters=10^6; I did the same and was actually surprised when it worked! I have got no idea why would people have problems with this one, it's really easy to solve В один из дней небеса сжалились на Сергеем Александровичем на-> над Does anyone know what this could be related to? I found the following test when got WA4: INPUT: aaa OUTPUT: 4 #include<stdio.h> #include<math.h> int main() { int n,k,i=1,s=1,t=0,temp=0; scanf("%d %d",&n,&k);
while(i<k) { s=s+i; i=2*i; t++;
if(s>=n) break; } while(s<n) { s=s+k; t++; } printf("%d",t); return 0; } while(s<n) { s=s+k; t++; } Isn't here (n-s)/k iterations? #pragma optimize( "g", on ) I got AC for maximum temas using Kosaraju. and for minimum I started with nodes with no incoming edge and searched until it hit previously found node (cycle) this is 1 team. For disconnected cycles, run dfs in similar fashion incrementing teams by 1. This question requires knowledge of Strongly Connected Component. If you don't know read about it. Good Luck !!! for max = number of strongly connected components. for min = ? Hi, I have submitted one solution with: new String("0").repeat(n) => n is one number, and the system not know repeat method for Java 1.8, what's about that?! It's core Java. Thanks, Jose > They fall until the total weight of the fallen stones exceeds k kilograms So weight of fallen rocks should be at least k + 1 Hi! Could you please check the next test case: ``` 3 2 1 2 1 3 3 1 2 ``` result should be `no`, but 4 my case i have `yes`. Despite this i had AC. Thanks in advance! Edited by author 13.05.2020 22:47 Edited by author 13.05.2020 22:47 Instead of searching for answer for m, search for sum - m Does anybody know what is so special about test no 29? I am positive that my solution is correct (which is obviously not the case) but it gets WA 29. I even compared it with a slow solution (BFS) but I did not find any differences. Please, I would really appreciate some help because I have tested all possible input combination for length 8 and the slow and fast solution produce the same answers. I FOUND MY MISTAKE :) Edited by author 17.06.2011 19:06 Edited by author 17.06.2011 19:06 test: 50 0000000000000000000000000000000000000000000000000000000000001 - 50 times 0000000000000000000000000000000000000000000000000000000000000 ans=2^50-1 : __int64 test: 50 0000000000000000000000000000000000000000000000000000000000001 - 50 times 0000000000000000000000000000000000000000000000000000000000000 ans=2^50-1 : __int64 Well, the length of the strings you provided are not 50 but 61, so the answer for this test is (2^61)-1 The correct test is 50 00000000000000000000000000000000000000000000000001 00000000000000000000000000000000000000000000000000 robbers dont know the path, so at each point take farthest node from robbers.do these fo for the length of shortest path and in the end take minimum of these. for lazy node propagation I did tree[n]+=(end-start+1)*lazy[n]; when start and end were integers. tree[n]+=(end-start+1)*(1ll)*lazy[n]; corrected error. i got TLE 21 I was able to reach 28 test in Python 3. Я дошел до 28 теста на Python 3. Edited by author 24.11.2016 23:52 Yes, I solved this problem using Python Yes, you just have to do some optimizations To all of you who cannot overcome #3 !!! All the suggestions about redundant '\n' and about that the dictionary may have repeated words have nothing to do with WA #3 (read condition carefully). If you use any kind of backward tracking, be it recursion or DFS, check the "no luck" condition attentively. First i used checking the next letter to be '\0' at the beginning of my recursion function, and if so returned 'true'. This is wrong! You must make word-end check BEFORE you make the next step, otherwise you may get "deadlock" "there is no direction to go" though there is no need to go anymore!!! Test word for the example table rabadaabracabrac: YES (starting from [3,1] in C-like indices). How did you get rabadaabracabrac: YES In the condition there is said,that words could not have self-intersections. But if you don't intersect you will not get this word. My program writes NO on this test Thank you, melkiy! I made the same mistake :( My program got YES on this test, by have WA#3 It's not a test case for WA#3: rabadaabracabrac: YES and it's not working. My reason for WA #3 was that I tried to use 1d char array to store the table and used i -> i - 1 to go left and i -> i + 1 to go right, however, if you are in the first column you can't go left and if you're on the 4th row you can't go right similar to strictly increasing subsequnce of length k just query and update BIT in reverse. Clang++ 4.0.1 - 0.39s - Accepted G++ 7.1 - 0.421 - Accepted Visual C++ 2017 - 1.029 - Time limit exceeded rofl in general i noticed that for the most problems clang is usually faster then g++ or ms c++ Edited by author 21.08.2018 03:53 I got it the other way - TLE #42 using G++ and Clang++, but AC 0.687 Visual C++ For WA3 try this: 3 1 2 1 Ans: 1 For WA12 try this: 5 1 2 3 1 5 Ans: 1 5 We have correct answers but on test 7 we have wrong answer Edited by author 08.05.2020 21:50 I had maintained dis[n+1][2] for distance. But visited array was vis[n+1], changed it to vis[n+1][2] and simple bfs. |
|