|
|
Общий форумTest: 1 10 of gg 3 1 of ff 10 of gg 9 of gg Correct Answer: 3 Edited by author 25.11.2021 23:40 You can always fill 2 * m area My program got WA1 with answer 1 2 3 4 1 2 3 4 on example test Why? tle 42 -ios_base::sync_with_stdio(0); but ios_base::sync_with_stdio(false); cin.tie(NULL); - ACCEPTED with 0.015) Is there a solution without randge tree structure? I use Fenwick Tree get AC,0.452 seconds There possible segment tree with uint16_t for indexes greater than 2^15, and uin32_t for less 2^15. (two arrays: uint16_t tree[N+N]; and uint32_t rem[32768] ) But I got WA38 (( I Got AC with segment tree!! uraaaaa. You can use segment tree where vertex is segment with length=4. 1 2 3 4 5 6 7 8 9 10 => [1,2,3,4] [5,6,7,8] [9,10,11,12] Memory is N*sizeof(int)+N*sizeof(bool) Complexity is N*log(N/4)*4+N*log(N/4) decomposition also works here, i've chosen amount of block about 300 I can't do that. C/C++. I am using two cycles. One to set up Fenwick tree and one to calculate the answer. Probably you are avoiding the use of the set up cycle somewhat. I tested my solution on war games 2 and have got 93 ms. UPD: got 46 ms on version 1 Edited by author 09.07.2017 22:20 Finally, I understood how to get rid of initialization cycle. Still TLE the same test 37. Maybe bitwise operations are faster with UNSIGNED integers... So, I tried to not calculate cnt=n-i+1 every iteration, made while (1) cycle, not call decrement on Fenwick tree after last soldier. TLE#37. My mistake was I was using queries for O(log(N) *log(N)) time in Fenwick tree But for that task, there are suitable queries in just O(log(N)) dp[i] - минимальное количество отрезков, если последний отрезок заканчивался в позиции i. ответ dp[m]. I've been struggling hard to overcome WA 8... Then I've made these test cases and got AC in one go. I hope these tests will be helpful to overcome WA... :) Case 1: 4 3 0 4 0 1 0 2 0 Ans: 2 1 2 Case 2: 2 2 0 1 0 Ans: 1 1 Case 3: 3 2 3 0 1 3 0 1 2 0 Ans: 1 1 Case 4: 3 2 0 1 3 0 2 0 Ans: 2 1 3 Case 5: 4 2 4 0 1 0 4 0 1 3 0 Ans: 2 1 3 Case 6: 5 5 0 5 0 5 0 5 0 1 2 3 4 0 Ans: 4 1 2 3 4 Case 7: 5 2 0 1 0 5 0 5 0 3 4 0 Ans: 3 1 3 4 Let me know if any1 finds any error... Thanks. Edited by author 20.06.2016 22:19 My program passed all this tests but still I have WA7 If you get WA22, problem in saving minimal price of devices. If there are several popular devices, you need to display the one with the cheapest price Try test: a htc 10000 b nexus 10000 c htc 99999 d nexus 10000 e htc 5000 f nexus 10000 answer is htc (the most minimal price is 5000) might it is very complicated but i use hash and dp to solve this problem There is always a solution and it is always only one -- you have n linear independent vectors (that is the determinant of the linear system is <> 0) and using Cramer's rule you have a single solution. But they are modular equations. Is Cramer's rule still valid for such equations? > There is always a solution and it is always only one -- > > you have n linear independent vectors (that is the determinant of the > linear system is <> 0) and using Cramer's rule you have a single > solution. Ok I understand that but i decided that there are bugs in my proof so ... 3 1 2 -1 2 3 -1 2 3 -1 Edited by author 17.07.2010 19:16 Edited by author 17.07.2010 19:16 Segments can be with zero length (p-1)(q-1) is euler function value of n. See some test cases below. I hope some of them will help you. 2 5 2 3 9 2 100 1 2 5 4 100 2 1 1 5 ans: 0 5 1 100000 0 1 100000 1 4 1 5 1 ans: 0 5 1 100000 0 1 100000 1 3 1 5 1 ans: 0 5 1 100000 0 1 1 1 4 1 5 1 ans: 100000 5 1 100000 1 1 1 1 4 1 5 1 ans: 99999 3 4 1 2 2 1 1 2 2 1 1 2 2 1 2 1 3 4 ans: 0 For WA16 these cases helped me: 4 6 1 1 1 2 2 2 2 2 2 3 3 3 4 4 4 4 4 4 4 5 5 5 5 4 2 2 3 1 ans: -1 4 6 1 1 1 2 2 2 2 2 2 3 3 3 4 4 4 4 4 4 4 5 5 5 5 4 2 3 3 1 ans: 1 It's strange that it has a tag "DP" as well. You don't need to sum the branches, you need to do binary OR "|" on them. On every step you move one level down. You have three choices to go down-left, down-right and just down (it's not always possible). So, you check which side m is on. If on the right, then we go down-right, otherwise - down-lef, if it's right below us, then we just go down The most important idea for this task is the fact that according to Lagrange’s Four Square Theorem, every natural number can be written as the sum of squares of four non-negative integers. Good luck, hope this will help! Edited by author 13.11.2021 00:26 Edited by author 13.11.2021 00:26 |
|
|