|
+3
So, I was thinking when to show my way to solve problems and I think that it's best if I do it only when at least I can solve three problems. So, like always don't focus on my code because it has less value that what I was thinking in the contest. A This problem I believe that everyone can solve but for example something curios that happen to me is that in the moment that I was writing the code for some reason I was doubting if 30 numbers after the first 3 or if the 3 count to the 30, but this problem it too simple and is about speed, so I decide to do the worst case that is that the count begin after the first three and search which are the first 30 numbers after the point and for the comparation of string use the length of the string that the problem give to make sure that I don't overflow or call something that doesn't exit. code B For this problem onward I began to use the best weapon that have the beginners in my opinion and is don't overcomplicate only try to solve it like if you were doing it at hand and write the way that your brain think to solved it and later past it to code, this is really useful when you see that they give you variables that are really small, for example in this problem $$$n = 50$$$, which mean that you only have to fill 50 values of the dice maximum and $$$t = 1000$$$, so even in the most wild case there are only 5000 dice to fill which is a number pretty small for a problem. My way of solving it was thinking in the simplest steps are the following:
code C The same as the problem B, begin to try to solved yourself and you will notice that if you sum the position that a number have been at each iteration the one that sum the smallest is the number that is first in the original and the one that sum the biggest is the last one in the original and with it if you see the other numbers the most true that is become, the small the total sum of position is of a number the more to the left this will be and in the other case the more big the more to the right is his position the original array. code D In this problem the reason that I see why someone couldn't do it are 3:
To solve the first one as a beginner I think that you must realize that you don't have anything to lose and that you must use it to your favor in a way that you always are pushing yourself to try to at least do one submit to prove that you try your best In the second one, to be real I don't understand binary search to deeply but I know to use the functions lower_bound() and upper_bound(), this is my way to pass question that need low time complexity And the third is that for example a nest of dolls that don't work is $$${1,2,4}$$$ but maybe you didn't read right that the different of each adjacent element is maximum 1, so my tip is to read a bit slower the more that you are close to the end of the contest. code Hope that my way of thinking can help you in some kind of way to your next contest. |
|
+30
So, I promise that as soon as I become pupil, I will try to give my perspective of how I make my solutions, I don't think that my code is worth but maybe my perspective can give you help in the future. A This one is the easiest, but I think that always that you read that you must give a number that is not the minimum or maximum of a list, you must think in make a vector, sort and print the position that you are interested. Like for example the second minimum would be a[1] or the second maximum a[n-2]. B The important thought that you must find is that if the maximum letter is 'a' you only need one and 'z' you need 26 and with only make in your mind the solution of two case you began to see what you need to do, I was a little nervous when I was writing the code and was thinking what is better if sort the string and see the last letter or used the function max_element, when you have dudes but you know that the code that you are in the middle of writing will work too, is best to commit to what you are writing in the moment that change to another solution in my experience. This work good in first or second problem for me because the solutions that you think probably will be right because they try to make easy for beginners like me, this is my way to be faster. Another useful type for the problems that want you to make a letter a number is remember that 'a'-'a' is 0 or a character minus the same character will return 0. C Here strike again the idea that we see in the problem A, in this problem you only care about the maximum and the second maximum so you make a vector, sort and use a[n-1] when the value x is not the maximum and a[n-2] if x is equal to the maximum, but I used a different method of only stored the two maximum numbers in a vector because I think a better version before beginning to write. D Is curious because I have come across this kind of problems many times that they want you to search there is a "Valley" or a "Peak" in the vector I still don't have a good way of approach this kind, but they always give you the conditions that must meet so the idea is always searching in a for if the condition is meet and see what are the corners case. In this case you want to focus in every point because you can make L=R, the segments with same numbers but for example if you have a segment equal to {3,3,3,3} you don't want to waste your time with {3},{3,3},{3,3,3} because they will contradict the condition a[l−1]>a[l] or a[r] < a[r+1] other that this is good to keep in mind that l=0 or r = n-1 are free passes. E this one is just in my reach of knowledge so when I find problems that seem difficult at the beginning, I always try to see what type of input I can solve and corner case to corner case I will build my solution.
Now it's apparent that the best is to make the last one a zero or the first one converted to one and see how much we gain or lost for each operation and after seeing if it is good to make a change, go for all the vector and every see how much it will give to the answer. Another tip is to use comments when you feel that you are confused about what you have done and what not. If you see my code is very inefficient but show that divide the problem in easy problems help you to see a solution. I hope that was helpful this in some way, sorry if was not as good as you expect, when I became a better, I will make up for these bad tutorials. |
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3408 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 154 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 146 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 135 |
| 9 | maroonrk | 133 |
| 10 | cry | 130 |
| Name |
|---|


