|
|
Общий форумWrite me 10 test, please ! Why do I have this error occurs in Python 3.x solution? The key here is "more than p, less than q", not "more than or equal to p, less than or equal to q" parabola function helps for you !!! k = x1 * x2 * (x2 - x1); a = y2 * x1 - y1 * x2; // a = (y2 * x1 - y1 * x2) / k; b = y1 * x2 * (x2 - x1) - a * x1; // b = (y1 * x2 * (x2 - x1) - a * x1) / k if(y[i] * k == a * x[i] * x[i] + b * x[i]) delete index i ... sum=0 a= ((int (i) for i in input().split(' '))) for j in a: sum+=j print (sum) Edited by author 30.04.2013 11:24 Edited by author 30.04.2013 11:25 There is a DP solution for this version of knapsack problem with O(n*max(wi)) time and O(max(n, max(wi))) space. It's a beat tricky, but still not so difficult in implementation. Just use your brains wisely ;) But an easy one is a brute-force, where we need to search between 2^n sets of piles. P.S. To admins, how about adding a new problem "Stone Pile 2" with N<=1000, 1<=Wi<=10000 and with writing the exact piles to output :) my code base 100000 accepted 0.015 s 112 kb f[i] = (i-1)*(f[i-1]+f[i-2]) Может кто-нибудь дать совет, как решить 27 тест и выше, сказать, в чём могут быть ошибки или дать приблизительный пример теста. всё, проблема решилась правильной ориентацией граней. офигеть!! кто-то ориентацию не написал и 27 тест, а я уже 2 часа перепроверяю код и не могу 11 пройти, хотя появление проблем я предвидел только при разрезании в нескольких плоскостях.... Edited by author 15.04.2013 03:23 вот такая же проблема, но на 10ом тесте тоже завис на этом тесте, только по Time Limit вылетаю... Program gives the correct answers. But I getting WA1. What is wrong? #include <stdio.h> int main () { int n, y, count; char x;
for (scanf ("%d", &n); n > 0; --n) { fflush (stdin); scanf ("%c%1d", &x, &y); count = 0;
if (x + 2 <= 'h' && y + 1 <= 8) ++count; if (x + 1 <= 'h' && y + 2 <= 8) ++count; if (x - 2 >= 'a' && y + 1 <= 8) ++count; if (x - 1 >= 'a' && y + 2 <= 8) ++count; if (x + 2 <= 'h' && y - 1 >= 1) ++count; if (x + 1 <= 'h' && y - 2 >= 1) ++count; if (x - 2 >= 'a' && y - 1 >= 1) ++count; if (x - 1 >= 'a' && y - 2 >= 1) ++count;
printf ("%d\n", count); } } I've just tested it on test in statement and get this answer: 2 2 2 How it's possible? I'm using Microsoft Visual C++ 2010, and get absolutely right answers. Look at the code. How can get the answer 2 2 2? I don't know why, but scanf sometimes read char and string wrong.I've got thet's problem, change scanf on cin and have AC.Please explain somebody why. var n,i,e,l,m,max:integer; s,maxw:string; begin readln(n); e:=0; l:=0; m:=0; for i:=1 to n do begin readln(s); if s[1]='E' then e:=e+1; if s[1]='L' then l:=l+1; if s[1]='M' then m:=m+1; end; if e>l then begin max:=e; maxw:='Emperor Penguin'; end else begin max:=l; maxw:='Little Penguin'; end; if m>max then begin max:=m; maxw:='Macaroni Penguin'; end; writeln(maxw); end. My first AC gives 1383 for the following test case when my second AC gives 1266 10 5 20 5 4 3 2 1 4 6 5 2 3 2 1 9 3 7 4 10 2 2 5 9 2 8 4 9 1 8 1 3 3 5 2 7 5 4 5 9 5 6 1 Your test was added. 85 authors lost AC. I think tests for this problem are weak. For example, there is no tests like 1000 2 2 2 1 1 1 4 4 4 3 3 3 ... 1000 1000 1000 999 999 99 My program works slowly on this test (nearly 0.5sec) but it's fly like a wind on submission Or give me some tests please. All tests that were proposed on the forum shows correct result. The main loop is: while (head != n) { if (id[head] != -1) { int have = shop[id[head]].count; if (have > 0) { if (want[head] > have) { if (head == n - 1) { ++time; break; } swap(id[head], id[head + 1]); swap(want[head], want[head + 1]); want[head + 1] = have; } else { shop[id[head]].count = have - want[head]; ++head; } } else ++head; } else ++head; ++time; } Edited by author 19.04.2013 14:14 Edited by author 19.04.2013 14:14 I think that the problem is in the function swap() which doesn't work in Java. Your guess is wrong. I wrote swap method. Also I used my own hashing. Maybe this is the root cause. please help to solve the problem One of my AC solutions will crash on test 200 3 1 200 200 199 199 1 and on many other like this one. (I'm never using vertex #200 in this solution) I did have problem on test 1 when read input data, good luck all and has fun. |
|
|