Show all threads Hide all threads Show all messages Hide all messages |
WA#18 | BOBUR_OG'O!!! | 1200. Horns and Hoofs | 2 Sep 2020 18:32 | 1 |
WA#18 BOBUR_OG'O!!! 2 Sep 2020 18:32 |
How come the suboptimal algorithms get accepted? | waddlepoof | 1200. Horns and Hoofs | 20 Apr 2020 12:07 | 1 |
I mean, there obviously must be some compiler optimizations that enable the O(K^2) algorithm to be accepted for the worst case. For example, I've tried binary search, given that this is a convex function, and the amount of branch prediction misses slows the thing down a lot. I've been looking at godbolt.org output and can't figure out what is happening here. |
Judge, Please, Help! Why fail in test #2? this is code | Alexander J. Villalba G. | 1200. Horns and Hoofs | 17 Apr 2020 02:34 | 1 |
I don't understand why my code fails. I have been very careful with all cases. The precision of the numbers, the zero and negative benefits, everything. My code should not have so many lines but I have put them for the frustration of having so many WA. Are you sure test # 2 is ok? Check it with my code. Previously I tried it with a much shorter code that reached test # 7 and failed, but it did not take care of rounding problems, this does and fails in test # 2 X-¿ Help, Please! // Brute force #include <stdio.h> #include <math.h> long calcMax (int horn_n , int hoof_n, float horn_b, float hoof_b ) { long max = (long) horn_b * horn_n + (long) hoof_b * hoof_n - (long) 100 * ( horn_n * horn_n + hoof_n * hoof_n); return max; } int passtoInt( char *number) { int num = 0, signo = 1, begin = 0; char decimal_flag = 'N'; int dec_ndig = 0; if( number[0] == '-') { signo = -1; begin = 1; } for(int i=begin; number[i] != 0; i++) { if(number[i] == '.') { decimal_flag = 'Y' ; continue; } if(decimal_flag == 'Y') dec_ndig++; if(dec_ndig > 2) break; num = num * 10 + (number[i] - '0');
} for(int i = dec_ndig; i < 2; i++) num = num*10; return num * signo; } void getPartEntAndDec(long num, long *ent, unsigned *dec ) { *ent = num / 100; *dec = num % 100; } int main(void) { char horn_s[14], hoof_s[14]; int horn_n= 0, hoof_n = 0, horn = 0, hoof = 0;
int horn_b, hoof_b; long max = 0, max1, max_ent; unsigned max_dec; int maxmount; scanf("%s%s%d", horn_s, hoof_s, &maxmount); horn_b = passtoInt( horn_s); hoof_b = passtoInt( hoof_s); for(int horn_n = 0; horn_n <= maxmount; horn_n++) { for(int hoof_n = 0; hoof_n <= maxmount - horn_n; hoof_n++) { max1 = calcMax (horn_n , hoof_n, horn_b, hoof_b ); if(max1 > max) { horn = horn_n; hoof = hoof_n; max = max1; } } } getPartEntAndDec(max, &max_ent, &max_dec ); printf("%ld.%02u\n", max_ent, max_dec); printf("%d %d\n", horn, hoof); return 0; } |
WA #14 | zaitsevmishka | 1200. Horns and Hoofs | 27 Dec 2016 21:04 | 1 |
WA #14 zaitsevmishka 27 Dec 2016 21:04 Can you please share some tests? Answer was correct on every test from forum, still can't pass test 14 + implemented all the hints, including rounding with 0.5000000001 and searching near the optimal values :( Thanks in advance! Edited by author 28.12.2016 02:12 |
Problem 1200 Horns and Hoofs has been rejudged | Vladimir Yakovlev (USU) | 1200. Horns and Hoofs | 3 Oct 2016 05:30 | 3 |
New tests have been added. All solutions have been rejudged: 288 authors have lost AC. Hm, TL #2 after rejudge... apparently old tests are changed too. Edit: i see, thanks~ Edited by author 03.10.2016 12:11 Old tests haven't been changed. Your solution's verdict on test #2 has changed from "slightly under TL" to "slightly above TL". There were a few such cases in total. |
Easy magic O(k) | [kubsu] Eugene Kudinov | 1200. Horns and Hoofs | 18 Nov 2015 02:53 | 1 |
// del Edited by author 26.11.2015 22:08 |
If you keep getting WA#13 | PrankMaN | 1200. Horns and Hoofs | 13 Mar 2015 22:37 | 1 |
Try this test: -1 -1 1 Answer: 0.00 0 0 |
What is test #7? | Alexey Krupnitskiy | 1200. Horns and Hoofs | 14 Nov 2014 17:17 | 1 |
could you give me test #7? I can not understand what is wrong! |
accepted | Sunnat | 1200. Horns and Hoofs | 21 Jan 2014 03:50 | 3 |
0.156s O(k) How to solve it faster? P.S. Cool problem) Edited by author 09.01.2013 16:32 |
Please give test 2 | Alexander Im | 1200. Horns and Hoofs | 24 Jul 2013 20:23 | 2 |
Please give test 2 for this problem. I don't know test#2. But I think that I know hint. Try this: 5 -5 20 Answer: 6.00 2 0 |
WA #14... again | nikitaevg | 1200. Horns and Hoofs | 8 May 2013 21:52 | 2 |
Hi, I have read all messages from the forum about this test 14, but nothing helps. Here is my code [code deleted] , what is wrong? Thanks in advance/ Edited by moderator 06.12.2019 20:41 Just instead of "if(res2>res1)" "if(res2>=res1)" |
Numbers don't have exaclty 2 digits after decimal point! | Alexey Dergunov [Samara SAU] | 1200. Horns and Hoofs | 25 May 2012 20:49 | 1 |
This code gets WA 1: long long readLL() { string s; cin >> s; s.erase(s.find('.'),1); stringstream ss(s); long long x; ss >> x; return x; } And this code gets AC: long long readLL() { double d; cin >> d; return ll(d*100 + 0.0000001); } |
WA #2 I did it correct, Why Wrong Answer??? | Sherzodbek | 1200. Horns and Hoofs | 2 Mar 2012 11:45 | 1 |
input: 2 2 10 Output: 2.00 1 1 Algo: cin>>a>>b; cin>>k; for(i=0; i<=k-1; i++){ for(j=0;j<=k-i; j++){ l=i*i+j*j; g=i*a+j*b; x=g-l; if(x>=r){n++; r=x; s[n]=r; si[n]=i; sj[n]=j;}}} for(int y=1; y<=n; y++){ if(s[n]==s[y]){ cout<<fixed<<setprecision(2)<<s[y]; cout<<endl<<si[y]<<" "<<sj[y]<<endl; } } Is it right? |
WA#7 | Adrian | 1200. Horns and Hoofs | 20 Jan 2012 19:10 | 2 |
WA#7 Adrian 30 Aug 2008 17:46 can anyone here tell me the test data for test#7? and thanks tell me please the data for this test Edited by author 20.01.2012 19:11 |
weak tests | ibra (TNU) | 1200. Horns and Hoofs | 9 Jan 2012 03:22 | 1 |
my AC solution works 0.218 sec and it is O(K^2), which is bad, and shouldn't be Accepted |
3 algorithms for you ! | Phan Hoài Nam (Harvey Nash) | 1200. Horns and Hoofs | 27 Aug 2011 20:51 | 2 |
1) Slow algorithm O(K*(K+1)/2) : brute force. AC : 0.2 ! -> Find the profit with each number of horn and hoof (horn + hoof <= k). 2) Fast algorithm O(K*2) : caching the optimal number of horns and hoof. AC : 0.031 ! Find : + The optimal number of horns <= k (A) + The optimal number of hoof <= k - num of horns (B) => result = A + B; 2) More Fast algorithm O(K) : caching the optimal number of horn or hoof. AC : 0.031 ! Caching the number of hoof. -> For each number of horn + The optimal number of hoof = 0 ... k - optimal num of horn. first algorithm could be optimized to AC in 0.046 :) |
Could someone give some extra tests,please...Thanks! | Vladimir Milenov Vasilev | 1200. Horns and Hoofs | 22 Aug 2011 08:04 | 5 |
input: -10000 -10000 10000 output: 0.00 0 0 input: -10000 -10000 10000 output: 0.00 0 0 I think your test data is wrong, Because K>=1, means you must produce at least one. I think your test data is wrong, Because K>=1, means you must produce at least one. You are wrong! "total amount of produced goods must NOT EXCEED K!!!" It means that A+B<=K. 0+0<=K 100% |
Test#12 | Tang RZ | 1200. Horns and Hoofs | 6 Mar 2011 11:53 | 5 |
What's the test#12? I failed!!! Could you help me? OK! I got AC! Here are my program: [deleted by moderator] Edited by moderator 29.05.2004 10:33 What did you do? i have WA 12 too.. Pls. give me any test fot it. (all test on this forum is accepted in my program) Thank you. This test helped me pass test #12 and get AC Here it is 11 23 3 Answer: 60.00 0 3 Good Luck! thanks for your data,i got AC ! 谢谢你的数据 我获得AC! |
Test #14 | aSSault | 1200. Horns and Hoofs | 30 Jan 2011 22:47 | 3 |
When my program had WA14, I changed there: if(a - int(a) >= 0.5) to if(a - int(a) >= 0.5 + 1e-7) And I get AC!! Maybe it will help you! Good Luck!!! Edited by author 05.05.2007 16:50 Please, help WA 14. How can I change this? I think there is my mistake: pr_x >= pr_y and pr_y >= pr_x ----------------------------- double a = input.nextDouble(), b = input.nextDouble(); double pr_x = 0, pr_y = 0; int x = 0, y = 0, k = input.nextInt(); boolean yes; while (true) { pr_x = a - 2 * x - 1; pr_y = b - 2 * y - 1; yes = false; if (pr_x > 0 && pr_x >= pr_y && x + y + 1 <= k) { yes = true; x++; } else if (pr_y > 0 && pr_y >= pr_x && x + y + 1 <= k) { yes = true; y++; } if (!yes) { break; } } System.out.printf("%.2f\n%d %d\n", a * x + b * y - x * x - y * y, x, y); } Edited by author 30.01.2011 22:48 |
Who can give me some tests,I got WA all the time!!Help!! | Ural_Yin Tong | 1200. Horns and Hoofs | 30 Aug 2010 12:46 | 8 |
> try these 11 13 12 : answer 72.00 5 6 11.01 13 12: answer 72.06 6 6 0 1 1000: answer 0.00 0 0 11 13 12: my answer is 72.00 6 6 why? I had the same problem too... I think 72,00 5 6 Edited by author 30.08.2010 13:02 thank you, your first test is really good. it helped me to solve problem successfuly)) the first test is really great! thank you :) |