| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Can someone explain me why's that test case is impossible? | Ivan | 1133. Последовательность Фибоначчи | 14 авг 2022 02:33 | 1 |
-1000 0 0 1 1 My solution do not deal with testcases like this, yet still was accepted. Am I missing something? For those who wonder, my program gives 9079565065540428013 on this testcase lol |
| hint | ironchat(ITMO) | 2123. Рюкзак | 13 авг 2022 10:27 | 2 |
hint ironchat(ITMO) 9 авг 2019 16:39 Simple solution, but try to optimize it! If you want better explanation (myironmistake@gmail.com) Simple recursion from highest weight down to lowest with proper cut-off on maximal reachable weight and caching of results gives AC in 0.015 sec and 1Mb RAM. I write that spoiler here because I suspects that tests are very weak because I have no proof of why this straightforward thing works so fast when problem has 4-sec/256Mb limits. |
| I think GCC and Clang can be tuned for better FPU performance | Harkonnen | | 12 авг 2022 11:38 | 1 |
Example - my submission 9959592 (problem 1990 - Podracing). It's not about input or sorting (checked everything), but GCC gives 0.5 sec where VC++ gives 0.171 sec (it was 0.9 sec on the verge of time limit when everything was double). FPU is just a guess because I faced situations before in real projects when GCC used FPU and VC++ used SSE or something else and was way faster, there was some command-line switch like -fdisable-fpu or -fdisable-387 or something like that for gcc (can't remember now), probably it will help. |
| Problem 1364 “LaraKiller”. The statement was updated. | Sandro (USU) | 1364. Поймать Лару | 12 авг 2022 10:38 | 2 |
The original version of the statement was unclear, and not all the limitations were described in the input data format. Both English and Russian version of the statement were updated. It's still unclear what to output if Lara has enough time to escape (i.e. there is no reason to hide) - empty output? My AC solution ignores that case like if entrance is locked. |
| What happened with my program on Test #24? | 198808xc | 1990. Гонки на карах | 12 авг 2022 10:04 | 2 |
My algorithm is linear, except the quicksort procedure. It gets TLE at Test #24. What happened? I have checked the program multiple times. Thanks. It's very weird - almost happened to me too (0.934 sec, dunno which test). After that I switched to 'int' and kept 'double' only for boundaries - it became 0.5 sec. Then I precalculated 1.0/(y[i+1]-y[i]) - timing didn't change. Then I suspected it was some anti-qsort case, tried to random-shuffle, even tried heapsort - no matter, still 0.5 sec. Then I've noticed that I am submitting it as GCC instead of VisualC (was testing another problem before on GCC/clang) - got 0.171 sec with same code :) GCC suxx. Dunno if it's input or sorting or what. I was using scanf/printf (cin/cout are slower in VisualC even with iostream::sync_with_stdio(false)). |
| HINT | Felix_Mate | 1926. Турнир интеллектов | 12 авг 2022 08:46 | 5 |
HINT Felix_Mate 30 дек 2016 20:18 When you count invM*rj*M mod M*pj you can get number > int64. But you can use this: a*b mod a*c=a*(b mod c). In our situation M*(invM*rj mod p[j]). Re: HINT http://xoptutorials.com/index.php/category/timus/ 1 янв 2017 23:44 WA5 is about this case (overflow test, WA9 and WA15 too), but formula I used still gets int64 overflow (chinese remainders), so I had to devise "short long arithmetics" (4 qwords to store result with base-2^32 digits, then fetching remainder via base-2^4 interpretation - that fits unsigned int64). Timing is still bad - like 0.14 sec, and was like 0.5 sec without bitwise optimizations. Your hint though allowed to fetch remainder via base-2^8 interpretation which shortened timing down to 0.062s sec. Edited by author 12.08.2022 05:27 Finally AC 0.031 without long arithmetics. Another hint - do not process primes one after another because in the end you will get a*b%c where both 'a' and 'b' are close to 2^63. Instead process first 9 primes individually and last 6 primes individually (product of both sequences is on the verge of 2^32). Then you may combine result within 2^64 using "dirty hack" mentioned by Felix_Mate :) P.S: I finally understood why you had 'inv' there, but in this case no mod operations are necessary at all (except during calculating inverse which is mod 47 at most), and this way of getting the answer (POW instead of GCD) works fine with sequential primes processing, no need to split them in two parts and pray for no overlow. |
| WA test 2 | andrei parvu | 1713. Ключевые подстроки | 11 авг 2022 17:25 | 8 |
Can somebody tell me how they passed test nr. 2 (or give me some good test cases)? I have a solution in O(N*M*log(N*M)) using suffix array and I can't find the bug. Thanks Edited by author 16.09.2010 22:39 I've got absolutely the same problem. I use suffix and lcp arrays. I use the following algo: for i = 1 to LENGTH_OF_ALL_WORDS l = the closest preceding suffix that belong to another word r = the closest succeeding suffix that belong to another word v = max(lcp(l, i), lcp(i, r)) + 1; w = the word that contains suffix i; if (v < ans[w]) ans[w] = v; I've tried lots of tests but can't find what's wrong. There is something strange with this problem. I hasn't written suffix array building on my own, I used a reference implementation. Looking for a bug I replaced it with code that builds suffix array in the naive way (i.e. literally sorting suffixes). I got AC! So there are 2 results: - The reference implementation I used is wrong :) - The test data seems to be weak because naive suffix and LCP arrays building gets AC. TO VC15 (Orel STU) max(lcp(l, i), lcp(i, r)) + 1 may longer than the word‘s length Edited by author 29.06.2012 13:49 Yes, it could be. In this case I don't change the answer for the word. 2 qwertyuiopasdfghjklzxcvbnm qwezrtyuiopasdfghjklzxcvbnmer My answers are: ert ez Or ert me Edited by author 11.08.2022 18:28 Try this 2 mississipi misisspi |
| Author could use L, r, /, \ for corners instead of pseudographics :) | Harkonnen | 1006. Квадратные рамки | 11 авг 2022 11:56 | 1 |
|
| How to solve it in O(N) | Victor Barinov (TNU) | 1130. Никифор на прогулке | 11 авг 2022 04:22 | 11 |
Hi everybody! I solved this problem, but my algo is O(n log n) and it works 0.14 seconds. Idea of my algorithm is to find two vectors witch sum is not greater than L and change them on their sum. It it possible to prove that such two vectors exists if there are more than two vectors in set. Do this procedure while we can find such two vectors. But many people solved it much better... I want to know this solution. Consider that for any vectors a,b,c, |a|,|b|,|c| <= L exists integers u, v, w, |u|,|v|,|w|=1, |ua+vb+wc|<=L It is not right: what are u, v, w for a = (5,0) b = (0,0) c = (0,5)??? L = 5, of course Many people above have solved this problem, but they didn't express their thought well. The key is this: if there are AT LEAST 3 vectors in the set with module not exceeed L, we can ALWAYS choose 2 of them and, with choosing the direction, make the module of their sum not exceed L. Thus, we can reduce the amount of vectors by this until there are only TWO. At last, for any two vectors which has the module not longer than L, we can make the module of their sum not exceed L*sqrt(2). And that's all the key. What's left is to find a way to programme. Maybe it will help you, maybe not for my poor English. Thank you for well-expressed idea. It really helps to understand the idea of solution to the problem. 2 Victor Barinov (TNU): complexity of my solution is not O(NlogN), but even O(N^2)! And it's AC 0.015 sec. Just use the same heuristics as in disjoint sets. Edited by author 04.07.2009 18:52 Edited by author 04.07.2009 18:56 Can somebody, please, prove the idea described by 198808xc? P.S. I've solved this problem using lot of cheating (brute force+random sort+heuristic) and would like to know, what is right solution. P.P.S. To prove it we should just realize the fact, that there is always 2 vectors, such, that angle between them is >=120 degrees. So their sum is <=L. Edited by author 14.07.2009 19:24 If you only two vectors, you're out of luck of getting |X+Y| and |X-Y| <= L when angle between them is more than 60 degrees (so together with their sum/diff they form an equilateral triangle). Now if you have 3 vectors, these 3 vectors and their reflections form a lotus (or a hexagon) which covers everything, so there will always be a pair with |X+Y| or |X-Y| <= L. When you're down to just 2 vectors, the worst situation is 90 degree angle which yields sqrt(2)*L. Your algo should be O(n) ;) I don't quite understand how write it with complexity of O(n log n) |
| Can anyone explain sample test? | Sq1 | 1805. Чапаев и шифровальная решётка | 10 авг 2022 11:59 | 2 |
Can anyone explain sample test? I have smth like this: Case n = 4, k = 1: 0000 0000 0000 1111 Case n = 4, k = 2: 0000 0000 0001 0111 Case n = 4, k = 3: 0000 0000 0001 1011 Case n = 4, k = 4: 0000 0000 0001 1101 Case n = 4, k = 15: 0000 0000 0011 1100 Matrix should not overlap itself after 90-degree rotations (no two '1' at same position) and should cover all NxN elements after 4 such rotations. |
| any algo | Ibragim Atadjanov (Tashkent U of IT) | 1805. Чапаев и шифровальная решётка | 10 авг 2022 11:56 | 8 |
any algo Ibragim Atadjanov (Tashkent U of IT) 12 ноя 2010 10:57 Who know how to solve it. I think all the varians will be 4^(9 + 7 + 5 + 3 + 1) = 4^25 when n = 10. So i cannot count from 1st to kth variant Re: any algo Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 12 ноя 2010 13:56 O(N^4) simple algo exists. Re: any algo Ibragim Atadjanov (Tashkent U of IT) 13 ноя 2010 18:52 Can you tell anything else? I mean is the algo search(Binary Search or smth else). Please give me a clue Re: any algo Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 13 ноя 2010 22:49 Suppose you have already built a part of a grille and is thinking what symbol is to put in the following cell. Can you count the number of grilles which can be built with such a beginning and symbol? I suppose that O(n^2) algorithm is even more simple. Both in inventing and coding. That's right. I track amount of remaining variations for every cycle and their total product. This information is enough at each of N^2 steps to decide if it should be '0' or '1' Given advices too weak to be helpfull. For me key idea was forming n*n/4 classes with 4 cell in each and working with level, where 1<=level<=n*n; We counting all combinations under level in each classes exept whose are used already. Re: any algo Strekalovsky Oleg [Vologda SPU #1] 8 ноя 2011 00:01 Given advices too weak to be helpfull. For me key idea was forming n*n/4 classes with 4 cell in each and working with level, where 1<=level<=n*n; We counting all combinations under level in each classes exept whose are used already. My algo was same as Vedernikoff 'Goryinyich' Sergey (HSE: АОП) said. Algo is very simple and wasn't too hard to implement. Edited by author 08.11.2011 00:01 |
| Тут же можно решить вообще не используя double ! | Toshpulatov (MSU Tashkent) | 1875. Angry Birds | 10 авг 2022 09:04 | 2 |
And also not using G constant :) |
| Anyone greedy? | alexradu04 | 1570. Ужин на 45 этаже | 9 авг 2022 23:15 | 2 |
I was wondering if there was a greedy solution to this problem help please. Yes, there is after preliminary DP for min-price-allowed-steps-graph. |
| Complexity | Infoshoc | 1570. Ужин на 45 этаже | 9 авг 2022 23:13 | 2 |
Solved with O(n * (m+max("filling value")) * 10^3). Anyone better? Strange thing: seems like in tests 15-16 max("filling value") is good deal smaller than 10.0, because O(n * (m+10) * 10^3) failed. There is 30000*100 solution O(filling X dishes) |
| when it may be «It is a lie!». | McArchuk | 1731. Укроп | 8 авг 2022 11:12 | 6 |
when it may be «It is a lie!». Edited by author 08.08.2022 11:27 |
| WA10 | markopetkovic359 | 1580. Долги декана | 8 авг 2022 09:20 | 4 |
WA10 markopetkovic359 4 апр 2010 08:23 Does anybody have an idea ? Edited by author 04.04.2010 08:24 6 6 1 2 1 2 3 2 3 1 3 4 5 1 5 6 2 6 4 3 Thanks. Was my bug as well (forgot that there can be more than one connected component). |
| Hint | Harkonnen | 1780. Код Грея | 8 авг 2022 00:13 | 1 |
Hint Harkonnen 8 авг 2022 00:13 Solution is pretty straightforward based on parity and bit position, but to avoid all those position reflections in your head during coding, generate codes for say N=5 and look at value of "k XOR x" |
| why i always get "Runtime error (access violation)" on the test №1? | vicodin | 1033. Лабиринт | 7 авг 2022 13:12 | 1 |
i found mistake :) Edited by author 07.08.2022 13:48 |
| Are there beautifull solution? | Joseph Puh the Battle Bear | 1578. Охота на мамонта | 7 авг 2022 12:22 | 3 |
Are there beautifull solution? The one other from bruteforce Yes, there are exists one very beautiful O(N^2) solution. But the practical complexity of this algo is much less :) There is also almost O(N) solution, but that's due to weak tests (probably there is a proof that N*log(N)) is enough. Just go forward and swap vertices if they form non-acute angle (that's WA14). Then go backward and do the same (that's WA22). Then do that in a loop 10 times back and forth, and get weak AC :) P.S: Even 2 such passes is enough (no proof, just such tests). And I think there is a proof that N passes is always enough. Edited by author 07.08.2022 12:28 Edited by author 07.08.2022 12:30 |
| Is there faster solution | DarksideCoder | 2129. Ипотека в Тридевятом Царстве | 7 авг 2022 09:47 | 3 |
My solution is O(tl^3logn) , but its performance is good. could you describe your solution? my algo O(logn * l^3 * t) has TL( i try to find solution like this: dp[i, a, l] , i is bit number, a is addition to i-bit, l is lost count Yes, there is. (L^2)*log(N) solution (0.187 sec). I DP on total amount of coins and amount of extra coins for next denomination (the latter is used to know how much more can I push forward when I advance a digit). The first index always increases by K-1, the second always increases by K, so it's kind of diagonal partial summing up matrix to itself. If you precalculate reachable sums properly, you can perform DP transfer in O(L^2). |