|
|
Common Boardrt Voroni diagrams perhaps (O(N*log(N)) I have AC 0.046s, O(K^3) with very simple approach Edited by author 14.04.2024 21:19 Can Anyone be kind enough to explain this ques to me? I'll be grateful to you.. When I tried the brute force algorithm, I TLE at #15 How to solve this problem? Please send the solution to 13588731339@163.com 1) When bruteforcing, random shuffle both m rows and n ships 2) When solving one subset sum problem inside bruteforcing, use bitset (array of bitsets) instead of bool array (2d-array). Instead of max() in subset sum problem, use operator OR and operator "right bit shift". Just search "subset sum problem bitset" and you'll find out. This will speed up your dynamic programming in 32 or 64 times (if you are using both 64-bit compiler and 64-bit processor) It will not totally solve problem, but you will get TLE#67 which is better and giving more hope :) Edited by author 12.04.2024 01:08 Edited by author 12.04.2024 01:09 Edited by author 12.04.2024 01:11 I tried this approach with Java: Test 5. TL With C++: Test 9. TL And seems like this is not enough, however time complexity is O(αk^2 + α|S|*k) where α is hash map hidden constant. So... did anyone managed to solve it this way? dp[i][j] - amount of i-digit numbers ending with j. therefore we form 2d table dp[n][2] then dp[i][0] = dp[i - 1][0] + dp[i - 1][1] dp[i][1] = dp[i - 1][1] It's not hard to see that dp[i][0] + dp[i][1] (i.e. number of all valid sequences) forms a fibonacci sequence. dp[i][0] + dp[i][1] = 2*dp[i - 1][0] + dp[i - 1][1] you can treat as f_n = 2*f_(n - 2) + f_(n - 3) But still, I don't know how to solve this problem :) Edited by author 23.01.2022 01:36 Edited by author 23.01.2022 01:37 dp[i][1] = dp[i - 1][1] is wrong, should be: dp[i][1] = dp[i - 1][0] Не вздумайте решать задачу, оно того не стоит. ( window | A | aisle |B C| aisle | D | window )-- Premium (1-2) ( window | A B| aisle |C D| aisle |E F | window )-- Business (3-20) ( window | A B C| aisle |D E F G| aisle |H G K | window )-- Economy (21-64) Edited by author 30.05.2022 16:38 It took me a while to get this one correct, and it's because I found part of the descritpion to be ambiguous/unclear - so I'm posting this clarification which hopefully will help anyone else who has the same misunderstanding. "if a student has got satisfactory marks, the scholarship is not given, " I read this to mean "got ONLY satisfactory marks" but my solutions were rejected. Once I modified my solution to treat it as "got ANY satisfactory marks", the solution was accepted. First time I've got WA #4 because of this test case: Input: 6 1 1 2 1 1 1 Correct answer: 2 1 1 2 3 1 Instead of using getline(cin, str), use two different string such as string s1, s2. Then compare s1! When n > 6 the cases are wrong. Try to do it without placing a circle in the center. How is it POSSIBLE to find 42 test case? It seems like everything should work fine.. OK, found my mistake. 777&222 would be very helpful test cases) already done. for someone who doesn't know how to do it: a,b = input().split() print(int(a)+int(b)) a = int(1) b = int(5) Edited by author 28.03.2024 16:23 What the output of? 2 0 0 1 1 1 1 2 2 i used redblack tree on python and using a quick input using stdin i passed test 8 time limit and met evening at 11 ok, it was a perpendicular but what about 15 test Just run Simpson's method, you will only need to find suitable "a", "b" and "N" parameters, but it can be done easily with trial and error method |
|
|