| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| WA6 | Lightless [Samara SAU] | 2089. Опытный тренер | 14 фев 2018 01:02 | 1 |
WA6 Lightless [Samara SAU] 14 фев 2018 01:02 Try this: 2 2 1 2 1 2 Ans: Yes 1 2 |
| How to fix WA 2 | Aditya Paliwal | 2093. Все дороги ведут в сугроб | 13 фев 2018 21:09 | 1 |
It is okay to use an edge if the next cleaning for this edge begins at the exact moment when you have crossed the edge. In other words a road is cleaned during the open interval (s_i, f_i). |
| No subject | IT | 1617. Ползуны | 13 фев 2018 16:03 | 2 |
Edited by author 12.03.2016 20:21 n = int(input()) a = [] summ = 0 for i in range(n): a.append(int(input())) b = list(set(a)) for i in range(len(b)): c=a.count(b[i]) if c > 3: summ+=c//4 print(summ) |
| eps | Anatoliy V Tomilov | 1369. Тараканьи бега | 13 фев 2018 15:32 | 4 |
eps Anatoliy V Tomilov 24 янв 2018 02:03 Epsilon to compare squared distances must be exactly 1.0 / (1 << 24) (at least for M*N algo). Even 23 and 25 leads to WA. Re: eps Anatoliy V Tomilov 5 фев 2018 17:11 (std::numeric_limits< float >::epsilon() / 2) is absolute accuracy needed overall. You can invent twofold float-then-double algorithm to sieve bad points beforehand. For single precision algorithm part you have to use 20.1f (20 + small constant) "epsilon" to compare squared distances in case if you use <= or >= operator (say, vcmpge_oqps or vcmple_oqps instructions) and 28.2f (28 + small constant) in case of strict inequality. Surely you can invent adaptive algorithm to infer relative accuracy needed in particular test case, which takes into account max abs differences of input point coordinates. epsilon should be explicitly specified in the problem statement, it is not hard to make a test to break even simplest O(n*m) double precision solution. Re: eps Anatoliy V Tomilov 13 фев 2018 15:32 I totally agree. The problem should be reformulated in integers or other way to make use of arbitrary precision numbers. Also 10000*100000 is too small dimensionality to encourage participants to make submissions of O((N + M) * log(N + M)) solutions due to high constant factor of latter. Stupid algorithm with randomization and trivial vectorization is faster (and extremely easier to implement) then clever algorithm with Voronoi and point location. |
| Why this DP solution doesnt work? | Dmitriy | 1353. Миллиардная Функция Васи | 13 фев 2018 06:22 | 8 |
I thought that this problem is so easy. After many tries to solve that I should say: that is not so easy and I cant solve it! Please, if you DP-master tell me where I'm wrong. So, the state is dp[sum][length] += dp[sum - digit][length - 1], for each digit 0..9. The base is dp[1..9][1] = 1. I've got WA#10: My program for 10 output: 43756 (correct answer: 43749) I can't find a little bug ;( [code] for s := 1; s <= S; s++ { for l := 2; l <= 9; l++ { for d := 0; d < 10 && s - d > 0; d++ { if dp[s - d][l - 1] == 0 { continue } dp[s][l] += dp[s - d][l - 1] if d == 0 { dp[s][l]++ } } } } [/code] You don't need to store previous positions: for (int position = 2; position <= 9; position++) for (int sum = 81; sum > 0; sum--) for (int digit = 1; digit <= 9; digit++) if (sum >= digit) ways[sum] += ways[sum - digit]; because you have to start l at one and eliminate continue and s - d >= 0 No. You are wrong here. I've found my error, it was a dp base. Thx for all. Guys, what are you doing in New Year? Hahaha |
| Wrong Answer || Compiler: GCC 7.1 | Meraj al Maksud | 1409. Два бандита | 13 фев 2018 04:59 | 3 |
I don't understand what's wrong with my code. Help me pls. Thnx in advance. #include<stdio.h> int main(){ int L, H; scanf("%d%d", &L, &H); printf("%d %d ", 10 - L, 10 - H); return 0; } It said not more than 10 cans... thus there could be less than 10 cans Once Harry and Larry shoot a common can... you gotta consider that too... |
| What is in 4 test? | Ilya | 1875. Angry Birds | 13 фев 2018 02:19 | 1 |
|
| WA 5...Please give some tests..Thx~ | Scau_Ly | 1508. Японский кроссворд | 11 фев 2018 18:38 | 2 |
I use Dynamic Programming..and i made several tests myself, my code could calculate the right answer = =...sorry for my poor English Simple tests: 1) 5 2 2 2 ????? ans:XX.XX 2) 4 2 2 2 ???? ans:Impossible 3) 15 3 2 1 2 ??X?.?.......X? ans:.?X?.X.......XX 4) 15 5 2 1 2 1 2 ??X?.?.X.?.?.X? ans:Impossible 5) 5 0 XXXXX ans:Impossible 6) 5 3 1 1 1 X.X.X ans:X.X.X 7) 5 2 1 1 .?.?. ans:.X.X. 8) 18 5 3 1 1 3 1 .???.X?.??..?XX?.? ans:.XXX.X..??..?XX?.X |
| asm tips | Anatoliy V Tomilov | 1369. Тараканьи бега | 11 фев 2018 13:26 | 2 |
asm tips Anatoliy V Tomilov 25 янв 2018 00:38 Make two separate arrays for x and y coordinates of cockroaches. Don't use horizontal instructions in tight loops. Perform all the develop and debug in 32-bit mode (evidently GCC/Clang on server has -m32 key). x86-64 has RIP-relative addressing, there would be bottlneck when you go back to 32-bit build and try to backport from 64-bit one. First loop for each sweet is straitforward. Don't use `displacement(base,index,scale)` addressing. Always run all over the `base` part. Finally it may give about a couple of hundred ms. In second loop for each sweet you may use BSF instruction to get least significant bit offset (remeber, judge runs on Sandy Bridge arch). Use LEA to calculate simple index arithmetic. Here is mine: size_type R = 0; asm ( "vbroadcastsd %[dmin], %%ymm5;" "dloop:" "vcmpgt_oqpd %[d](,%[i],8), %%ymm5, %%ymm6;" "vmovmskpd %%ymm6, %%eax;" "test %%eax, %%eax;" "jz rnext;" "rloop:" "bsf %%eax, %%edx;" "lea 1(%%edx,%[i]), %%edx;" "mov %%edx, %[results](,%[R],4);" "inc %[R];" "lea -1(%%eax), %%edx;" "and %%edx, %%eax;" "jnz rloop;" "rnext:" "add $4, %[i];" "cmp %[M], %[i];" "jl dloop;" : [R]"=b"(R) : [d]"m"(d), [dmin]"m"(dmin), "0"(R), [results]"m"(results), [M]"r"(M), [i]"c"(0) : "cc", "memory", "%eax", "%edx", "%ymm5", "%ymm6" ); Custom IO gives about 300+ ms. I hope M*N solutions finally will loose their ACs someday (at least until hardware will be updated to AVX512-compatible). It turns out, that there are possible two way to solve this problem (both M*N) in addition to naïve one (1400ms). 1.) Read all sites, then for each query point do find all the preliminary neighbours using float coordinates (it is almost two time faster in terms of membory bandwitdth, then if use double). This is a "float" sieve. Then for all sites passed "float" sieve perform similar "double" sieve. It get about 500ms (for me from 1.45s to 950ms). Test #16 is still hardest. Prefetch instructions in long runs gain up to 100ms. First loop (precalc of squared float distances) can be unfolded 4 times by query points (vbroadcastss from fixed memory location works fast in loop, you should not occupy dedicated ymm register for these). Second loop, where squared distances compared against least distance (+ eps of course), found in previous loop, can be unfolded 4 times (you can occupy all 32 bit of some register using bit shift (ror, rol) after vmovmskps). I think it allow to better utilize branch prediction mechanism. This approach can be beaten by simple test: cloud of sites in one corner in 10x10 square and cloud of query points in opposite aslo in 10x10 square both in general position (not matters much). Or wiser: query points placed on quarter of circle with center in one corner and radius of 20000, sites on another quarter of circle with center in the same corner and small radius or vice versa. Or even: two distant strait lines: one with query points and another with sites. 2.) You can solve the problem in single loop using just doubles with randomization. If your random numbers hit right sites, then you can probably make even fastest solution (but it is too improbably). I can't find counterexample for this randomized approach. I am very interested in Progbeat's solution details. It seems (by memory consumed) he used approach very similar to mine. It would be great if we'll exchange our solutions somehow =). |
| Как вибирать из двух одинаковых по длине ответов? | Bazeev Damir | 1651. Кратчайшая подцепь | 11 фев 2018 10:40 | 1 |
17 1 2 3 4 5 6 7 2 8 9 5 10 8 9 11 3 9 1 2 8 9 1 2 3 9 ?????????????????????????????????????? |
| I got WA on test 9, please give me some sample data, I'm desperate | Dan Stefan | 1043. Закрыть дугу | 11 фев 2018 04:01 | 7 |
I suspect rounding errors or something I have WA#9 too. The program seems to be right. Who can help me? I think, that your calculations not so are exact, as that is demanded with a problem. Try to not use intermediate values (for example radius etc.). Re: morbidel 31 янв 2005 18:27 you have all tests on timustests.4t.com Re: UNKNOWN_LAMER 31 янв 2005 22:22 Thank you very much. You were right about my bug. I have just change in my C++ code ceil(x) to ceil(x-eps) and floor(x) to floor(x+eps) and got AC!
Hey, UNKNOWN_LAMER! Do I know you from somewhere? Re: estefy 11 фев 2018 04:01 je Edited by author 11.02.2018 04:58 |
| Solution | Gilles Deleuze | 1268. Маленький Чу | 11 фев 2018 01:49 | 1 |
Solution Gilles Deleuze 11 фев 2018 01:49 |
| AC in 0.015 | Aditya Singh | 1118. Нетривиальные числа | 10 фев 2018 15:29 | 2 |
[code deleted] Edited by moderator 19.11.2019 23:40 Hi, Very good solution! Just one note, it doesn't affect AC, but: In D+=(i+N/i); if (i == N/i) you don't need to add both i and N/i, but just i. In this case result of check(N) will be 100% equal to triviality(N) in all cases. |
| for n = 10, k = 2, ans = 89. How?? | iOli | 1009. K-ичные числа | 10 фев 2018 08:18 | 1 |
|
| Test 26 | Vitaliy Herasymiv | 1866. Стихотворный размер | 9 фев 2018 20:43 | 3 |
Test 26 Vitaliy Herasymiv 15 окт 2011 15:07 Please, check test #26, it seems to be incorrect. Oh no, that test is correct! I got AC. |
| WA 4 | Bazeev Damir | 1651. Кратчайшая подцепь | 9 фев 2018 19:53 | 1 |
WA 4 Bazeev Damir 9 фев 2018 19:53 |
| Test 6 | Shorekh | 1131. Копирование | 9 фев 2018 04:11 | 2 |
Test 6 Shorekh 20 окт 2016 22:48 Whoever gets Wrong Answer at 6th test, try to change your way of finding the power of two. My solution got WA#6 when I calculated power of two this way: power = ceil(log(x)/log(2)); Better calculate it by multiplying it. |
| what about Ramanujan's 1729 | Adkham | 1349. Ферма | 8 фев 2018 19:27 | 1 |
I remember once going to see him when he was ill at Putney. I had ridden in taxi cab number 1729 and remarked that the number seemed to me rather a dull one, and that I hoped it was not an unfavourable omen. "No," he replied, "it is a very interesting number; it is the smallest number expressible as the sum of two cubes in two different ways." G.H.Hardy 1729 = 1^3 + 12^3 = 9^3 + 10^3 |
| what is wrong with my code ??? | Adkham | 1110. Степень | 8 фев 2018 02:23 | 1 |
#include<iostream> #include<cmath> using namespace std; int func(int k, int n, int m) { if(n == 0) return 1; else return func(k, n-1, m)*k%m; } int main() { int n, m, y, x, i = 0; int b; bool flag = true; cin >> n >> m >> y; if((n >0 && n < 999) && (m > 1 && m < 999) && (0 < y && < 999)) { while(i < m) { x = func(n, i, m); if(x == y) { cout << i << ' '; flag = false; } i++; } if(flag) cout << "-1"; } else cout << "-1"; return 0; } Edited by author 08.02.2018 02:25 Edited by author 08.02.2018 02:27 |
| Solution is pretty easy | Gilles Deleuze | 1109. Конференция | 7 фев 2018 21:51 | 1 |
Firstly, the problem asks to find number of edges in minimum edge cover Secondly, the number of such edges plus the number of maximum matching equals to number of vertices, that is N + M Thirdly, you can find the number of max. matching easily with dfs-like algorithm (you can find code online). The answer is N + M - (number of max. matching) |