Show all threads Hide all threads Show all messages Hide all messages |
Why nothing mentioned buying twice? | coolboy19521 | 1326. Bottle Taps | 6 Jul 2024 19:09 | 2 |
I solved the problem the way I understood it but then when staring at the discussion page I discovered that buying the same tap twice is allowed. Nevermind :) Just a slight change in the code fixed everything. Nice problem. Edited by author 06.07.2024 19:09 |
Some tests | Loky_Yuri [USTU Frogs] | 1326. Bottle Taps | 1 Nov 2022 11:08 | 2 |
Some tests Loky_Yuri [USTU Frogs] 27 Jul 2009 21:10 These two tests helped we find my bugs. Test 2 1 3 0 2 1 2 The answer is 4. Test 3 10 20 30 1 29 3 1 2 3 2 1 2 The answer is 29. Hope it will help you too. Indeed helpful. You may buy more taps than you need. |
Почему - то после того после АС на этой задаче хочется радостно кричать. | Mahilewets | 1326. Bottle Taps | 24 Jul 2017 19:41 | 3 |
И не только мне, как показывает форум. Можно решить это с помощью алгоритма Дейкстры. Моё время на Clang C++14 равно 2.7 сек. На Visual C++2013 вообще TLE#8. Стало понятно от чего кайф Из-за того что я еле-еле успел в time limit Ожидания были, что случится memory limit с большой вероятностью, поэтому я взял сразу Visual C++ |
I got AC, but my algorythm is standart( O(m*2^n) ). How solve faster? (i need in idea) | Felix_Mate | 1326. Bottle Taps | 3 Feb 2017 21:08 | 3 |
Hi. I've also got AC with O(m*2^n), but it seems that it's a bit more fast. Here's an idea. Each set of taps or a combination of sets has corresponding bit mask. We have an array int minPrice[2^N]. Obviously, index is a mask, element — min price for buying such combination of taps. Initially the only !=0 elements are those each corresponding to one of predefined M sets. Then the DP comes. We go from 0-th element to the last (11...1 target). If i-th element !=0, we process it: a) if i corresponds to one of M predefined sets, we try to OR "i" with all younger mask with !=0 price. b) if i doesn't correspond to any predefined set, thus, it's a combination of some predefined sets, then we OR this "i" with younger predefined masks ONLY (not all younger "j" !=0). However, there's still a question to those guys who got AC in less than 0.1 second. Especially to those who did it in ~200 KB. |
Unclear problem statement in russian | Sirko | 1326. Bottle Taps | 31 Jan 2017 15:21 | 1 |
"В первой строке записано число N — количество недостающих Петрову крышек (1 ≤ N ≤ 20)." vs "В последней строке перечислен минимальный набор крышек, который Петров намерен купить в любом случае." |
WA #7 Please can you give me some TEST! | Tukenov | 1326. Bottle Taps | 26 Dec 2014 13:08 | 1 |
Edited by author 26.12.2014 13:39 |
How to use dynamic programming with bitmasking? | Nikunj Banka | 1326. Bottle Taps | 26 Dec 2013 00:01 | 3 |
Taking hints from the forum I am using dynamic programming with bitmasking. But I cannot understand how to memoize the results as the number of subproblems are very large. ie. 2^n * m that is 2^20 * 120. I am getting Memory limit exceeded. Is there a better way to define the states of the dp? Yes. You have the matrix dp[120][2^20]. There is only transitions from n-th to (n+1)-th row of the matrix. So, you need to memorize only 2 rows (previous and current) instead 120. There is solution with only 2^n memory (not 2 arrays, but just one) |
AC......but too slow! | Yu YuanMing | 1326. Bottle Taps | 8 Oct 2013 23:08 | 5 |
I regard it as a graph theory problem,and solve it in O(M*2^N). But it is very slow,so I would like to hear some others' algorithm.Maybe we can make progress together. Contact me: yym2008@hotmail.com Just get only bottles he wants (ignore others). Perform mix-up by bit-wise OR (I think you did it). And use heap for Dijkstra - it works very well because |E| < |V| thanks Denis Koshman, first i Time limit exceeded in test 11, when i use your hint i AC in 0.453 s, i dont forgot your hint in all my life :D. GOOD LUCK!!! How can I regard it as a graph theory problem??? What do edges mean and what do vertex mean? Edited by author 17.05.2012 18:31 ive got the same problem my solutions (both using function w/ memoization and precomputing all the possible bitmasks before answering) pass the time limits but are 6-7 times slower :| |
What is the answer for this test? | pmartynov | 1326. Bottle Taps | 8 Oct 2013 23:04 | 3 |
4 20 11 12 23 3 17 2 1 3 25 3 2 3 4 15 2 3 4 3 1 3 4 What is the answer? 32 or 35? If 32, how is it possible to do that less that O(2^(N+M))? English version says AN optimal offer. Russian says: Осталось выбрать оптимальнЫЕ предложенИЯ (plural). What to choose? |
advice to those who use set instead of heap | Lavrentiy Palovich | 1326. Bottle Taps | 6 Jul 2011 17:09 | 2 |
use priority_queue, it eats less memory Use array, it eats less memory =))) |
To Admins: Bad Tests (+) | Victor Barinov (TNU) | 1326. Bottle Taps | 17 Nov 2008 13:03 | 6 |
The set of tests is not so good, because optimized backtracing can get AC in 0.015 sec and 129 Kb on Pascal. Try to add more good tests. I think there is no this test: 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 This simplest test will be bad for some good optimazed brute forces... Try spend little time to find some "good". PS To Vladimir Yakovlev, give me please your e-mail, I can say more about this problem but not in the forum. Thanks! My optimized Brute-Force runs 0.015 Sec , and is also VERY VERY fast against your data... Backtracking is still acceptable Some new tests were added. The problem was rejudged. About 130 solutions got WA and TL. |
WA #4 | Faeton (Kyiv - Mohyla Academy) | 1326. Bottle Taps | 18 Feb 2008 21:52 | 1 |
WA #4 Faeton (Kyiv - Mohyla Academy) 18 Feb 2008 21:52 could anyone give me some tests? |
Who can give me some good test? I've got WA. | Alexey | 1326. Bottle Taps | 6 Jun 2006 23:04 | 1 |
Please, help to make it AC... Thanks. |
Who can better? | Tolstobrov_Anatoliy[Ivanovo SPU] | 1326. Bottle Taps | 21 Sep 2005 03:28 | 2 |
I can better Anatoliy 'Tolyan_NO' Tolstobroff 21 Sep 2005 03:28 |
I got AC!!! | I am get tester... | 1326. Bottle Taps | 12 Sep 2005 18:39 | 1 |
time 2.671 memory 2349 I am happy!!! |
Jooooooooouuuuuuuuuuuuuuuuuu! I did IT!!! | BELOCHUB | 1326. Bottle Taps | 10 Oct 2004 21:38 | 1 |
Jooooooooouuuuuuuuuuuuuuuuuu! I did IT!!! Whole day!!!! I'm satisfied! Hi to all from BSU! |
keep getting wrong answer | Emilian Miron | 1326. Bottle Taps | 21 Sep 2004 19:59 | 2 |
I code the offers as bitmaps and calculate the cost of every bitmap. This gives 2^N configurations. Then the algorithm is dynamic programming or minimum path in a directed acyclic graph. Please help me see where I am wrong. Here's part of my code /* variables */ int prices[maxn]; struct offer { int tapcode; short int price; } offers[maxm]; int N, M, goal; short int cost[1 << maxn]; void solve(void) { int tapcodemax = 1 << N; int i, tapcode, k, j, sol; short int ccost; /* compute initial costs based on individual prices */ for (i = 0; i < tapcodemax; i++) { tapcode = i, ccost = 0; for (j = 0; j < N; j++, tapcode /= 2) if (tapcode & 1) ccost += prices[j]; cost[i] = ccost; } /* consider special offers */ for (i = 0; i < tapcodemax; i++) for (k = 0; k < M; k++) if (cost[i | offers[k].tapcode] > cost[i] + offers[k].price) cost[i | offers[k].tapcode] = cost[i] + offers[k].price; for (sol = cost[goal], i = 0; i < tapcodemax; i++) if (((i & goal) == goal) && sol > cost[i]) sol = cost[i]; printf ("%d\n", sol); } Edited by author 30.08.2004 01:48 This part which you give is right ... maybe the inital part is wrong.. |
No subject | Sun Hong | 1326. Bottle Taps | 24 May 2004 10:10 | 1 |
Edited by author 25.05.2004 09:09 |
What's the problem mean??? | jimmystart | 1326. Bottle Taps | 23 Apr 2004 10:43 | 1 |
What is that seperate in n lines and m lines ? I don't understand it. |
could Petrov bye the same bottle taps twice? | 长郡丢B小分队(History,Jelly,Eye,Fish) | 1326. Bottle Taps | 16 Apr 2004 15:19 | 3 |
input 4 100 100 100 100 3 17 2 1 3 25 3 2 3 4 15 2 3 4 3 1 3 4 Is the answer to this data equal to 32(17+15)? or there is no answer? Yes ,I didn't understand THIS too But what could u guys got AC without sloves this question? Surely. The only restriction on shopping - needed taps should be present at the end |