Common Board| Show all threads Hide all threads Show all messages Hide all messages | | What outputs is correct? | Innokentiy | 1345. HTML | 7 Jan 2016 14:09 | 2 | input1 sd5=#124'ashds'#12#154'sah'; input 2 sd5:=#123+#12; output1: sd5=<span class=string>#124</span><span class=string>'ashds'</span><span class=string>#12</span><span class=string>#154</span><span class=string>'sah'</span>; | | Test 1 | sherbina_evgeniy | 1863. Peaceful Atom | 6 Jan 2016 21:02 | 2 | Test 1 sherbina_evgeniy 27 Sep 2014 12:33 I got WA1 and I don't understand why. Give me some tests please. Re: Test 1 Tolstobrov Anatoliy[Ivanovo SPU] 6 Jan 2016 21:02 Test #1 describe into problem statement. 10 3 3 4 5 1 What it means, we have range [0, 10] and start position in 3. And have 3 shifts. First shift we can go from 3 to [-1, 7] as -1 not in range we have only [7] positions. Second shift we can go to positions [2, 12] as 12 not in range we have only [2] position. Third shift we can go to positions [1, 3] as all of them in range we have 2 possible final states 1 and 3, minimal of them 1 and maximal 3. Answer will be 1 3. Another test: 100 50 4 1 2 4 8 Possible positions on steps: 0) [50] 1) [49, 51] 2) [47, 49, 51, 53] 3) [43, 45, 47, 49, 51, 53, 55, 57] 4) [35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65] Answer will be 35 65 | | clockwise order) | -XraY- | 1185. Wall | 6 Jan 2016 13:03 | 2 | What does it mean: "clockwise order"? How do you define clockwise order in notconvex polygon? For example: in picture like a snail what roundabout way is turned in the clockwise direction and what is not? Sorry for bad Enlish... Hi. Can you remember, what was the problem with test 14? | | AC! O(n^6)???????? | waterlink | 1034. Queens in Peaceful Positions | 6 Jan 2016 12:54 | 3 | how could it have been passed??? and with 0.031 because of the test cases are to easy.... you can use (next_permutation) easyly... | | WA test #5 | Blum | 1181. Cutting a Painted Polygon | 6 Jan 2016 11:55 | 4 | Can anyone give me some tricky tests? 5 RGRBG 7 RBGBRGB 6 RGBGRB 4 RRBG | | No subject | Safayet Islam Anonn'o | 2066. Simple Expression | 6 Jan 2016 00:03 | 11 | No subject Safayet Islam Anonn'o 18 Oct 2015 16:00 Can I get some test inputs please? But in problem description "You are not allowed to use unary minus and parentheses in the expression", so 1-1-2 is not correct Edited by author 21.10.2015 16:37 Unary minus and usual minus are different things... [code deleted] Edited by moderator 24.11.2019 13:46 5 2 1 answer: 5-2-1 = 2 your program would say 3 For 5 2 1, it's -9. Numbers can be placed in any order. input numbers are nondecressing order so you can't put 5 2 1 | | WA 8. | __Andrewy__ | 1525. Path | 5 Jan 2016 20:41 | 6 | WA 8. __Andrewy__ 4 Jan 2016 17:48 const Nmax=111111; var path:array[1..Nmax] of char; N,M,K,pic,d,dmax,i,L,now:longint; ch:char; ans1,ans2,ans3:int64;
begin readln(N,M,K); L:=0; read(ch); while(ch='u')or(ch='d')or(ch='r')or(ch='l')or(ch='f')or(ch='b') do begin inc(L); path[L]:=ch; read(ch); end;
pic:=1; d:=1; dmax:=1; now:=1; for i:=1 to L do begin if(path[i]='l') then begin if(now=1) then begin inc(d); if(dmax<d) then dmax:=d; end else begin dec(now); if(now=1) then begin d:=1; if(dmax<d) then dmax:=d; end; end; end; if(path[i]='r') then begin if(now=N) then pic:=N else begin inc(now); d:=0; if(now>pic) then pic:=now; end; end; end;
ans1:=1; i:=2; while(i<=N)and(pic<N) do begin if(i-1>=dmax) then inc(pic); if(i-1>=dmax)and(pic<=N) then inc(ans1); inc(i); end;
pic:=1; d:=1; dmax:=1; now:=1; for i:=1 to L do begin if(path[i]='d') then begin if(now=1) then begin inc(d); if(dmax<d) then dmax:=d; end else begin dec(now); if(now=1) then begin d:=1; if(dmax<d) then dmax:=d; end; end; end; if(path[i]='u') then begin if(now=M) then pic:=M else begin d:=0; inc(now); if(now>pic) then pic:=now; end; end; end;
ans2:=1; i:=2; while(i<=M)and(pic<M) do begin if(i-1>=dmax) then inc(pic); if(i-1>=dmax)and(pic<=M) then inc(ans2); inc(i); end;
pic:=1; d:=1; dmax:=1; now:=1; for i:=1 to L do begin if(path[i]='b') then begin if(now=1) then begin inc(d); if(dmax<d) then dmax:=d; end else begin dec(now); if(now=1) then begin d:=1; if(dmax<d) then dmax:=d; end; end; end; if(path[i]='f') then begin if(now=K) then pic:=K else begin d:=0; inc(now); if(now>pic) then pic:=now; end; end; end;
ans3:=1; i:=2; while(i<=K)and(pic<K) do begin if(i-1>=dmax) then inc(pic); if(i-1>=dmax)and(pic<=K) then inc(ans3); inc(i); end;
write(ans1*ans2*ans3); end. Рассуждения такие: 1)как только достигнуто значение верхней границы,то все последующие шаги бессмысленны,т.к. пути совпадут; 2)пока первые i точек попадают в минимум у 1-ой точки (т.е. можно построить график зависимости номера шага от его значения,причем за пределы значений нельзя выходить и потому строим график в этом случае параллельным оси шага),их всех(кроме 1-ой точки) не засчитываем,все оставшиеся(если есть) и дают ответ; 3)всё перемножаем. Re: WA 8. Jane Soboleva (SumNU) 4 Jan 2016 19:12 Сложновато как-то... моя var-секция выглядит так: var x, y, z: int64; curlr, minlr, maxlr: longint; curdu, mindu, maxdu: longint; curbf, minbf, maxbf: longint; c: char; begin ... UPD: да, и ещё, рекомендую всё-таки while not eoln do begin read(ch); ... вместо read(ch); while(ch='u')or(ch='d')or(ch='r')or(ch='l')or(ch='f')or(ch='b') ... Потому что этот второй цикл означает, что в какой-то момент будет произведена попытка считать ещё один символ, когда всё уже считано. У меня этот код при тестировании на файле иногда работает, а иногда выдаёт рантайм 201. Но если в конце второй строки делать Enter, переход на новую, то конечно проблем не возникнет, но ведь в тестах этого не гарантируется. UPD: Вот простейший тест, на котором валится. Почему именно неправильно работает, не скажу, слишком сложные вычисления какие-то. 8 1 1 llllrrrr 4 (правильно.) 8 1 1 llllrrrrrrrr 1 (правильно.) 8 1 1 rrrrllllllll 4 (неправильно.) Edited by author 04.01.2016 20:59 Изменил прогу,всё равно WA. Jane Soboleva (SumNU),я правильно рассуждаю?:я ищу 3 максимума-dmax-максимальное время,когда мы были в 1,maxb-максимальное смещение(вправо от 1) до dmax,maxa-максимальное смещение вправо уже после dmax. Т.е. если строить график пути,то r означает поднятие по оси OY,а l-спуск.Тогда мы как бы начинаем в 1 и с шагом 1 то увеличиваем ординату,то уменьшаем,причем попав в 1 мы не можем идти вниз,а потому движемся вправо,то же и с N.В итоге я ищу максимальную высоту до "ямы" длиной dmax и после. Потом рассматриваю точки i>=dmax+1,т.к. все точки меньшие попадают в яму и потому все пути совпадут.Остальные точки смещены на dmax от графика первой точки и потому они дают новые пути,если не проходят через N(ровно одна из них может проходить),т.к. значения возрастают и потому пути снова совпадут. Re: WA 8. Jane Soboleva (SumNU) 5 Jan 2016 01:36 Не уверена~ К сожалению, я сейчас не в состоянии сказать, насколько эти рассуждения правильные. У меня алгоритм был такой: я поместила робота в условную точку (0, 0, 0) бесконечного параллелепипеда, а потом просто двигаю его согласно заданной строке, параллельно отмечая самое дальнее расстояние в каждом из измерений, которое он достигает в процессе. То есть, к примеру, после rrlllll будет minlr = -3 и maxlr = 2, и расстояние = maxlr - minlr = 5 (2 - -3). И так я считаю для каждого из трёх измерений. После всего этого я получаю три таких расстояния, и вычитаю их из соответствующей им размерности измерения, а потом все эти три числа перемножаю. Вот и всё. Ну и единственный нюанс — надо проследить, чтобы каждый из трёх множителей не опустился ниже единицы, то есть хотя бы одна позиция должна остаться. Например, у нас по left/right размерность 5, и у нас lrrrrrrrr, получатся minlr -1, maxlr 7, 7 - -1 = 8, 5 - 8 = -3, -3 меньше 1, поэтому вместо -3 мы подставляем 1 при умножении. Edited by author 05.01.2016 01:39 Спасибо за идею! Правда я не совсем понял корректность,но решил по-своему: как и ты(или Вы?) нашёл максимальное смещение влево и вправо,а потом осознал,что нас интересуют такие i,что 1-minlr<=i<=N-maxlr(это получается из системы i+maxlr<=N-кол-во i,не выходящих за правую границу и i-minlr>=1-за левую;все пути остальных i совпадут в конечной точке,а если же таких i нет=> все они выходят по крайней мере за одну границу и ответ 1). Кстати,из таблицы рейтинга решений видно,что ученик превзошёл учителя))) Edited by author 05.01.2016 13:38 Re: WA 8. Jane Soboleva (SumNU) 5 Jan 2016 20:41 Можно на ты :) Поздравляю!~ Да, в этот раз решение уже более похожее на моё. Насчёт памяти — у меня даже на задачу A+B не получается тратить меньше 140кб сейчас, хотя у некоторых, я вижу, выходит около 80 и меньше. Возможно, надо просто отключать или менять какие-то директивы компилятора, но я с этим не заморачивалась. | | what right answer for this test? | zbsGuy | 1218. Episode N-th: The Jedi Tournament | 5 Jan 2016 16:10 | 3 | 6 one 7 4 5 two 6 3 10 three 5 10 9 four 7 6 7 five 2 5 8 six 3 3 3 I think : one, two, three, four, five. Edited by author 18.03.2009 20:44 test is incorrect, two and six have equal second parameter | | Compliler Bug | José Wagner | 2064. Caterpillars | 5 Jan 2016 01:46 | 3 | My submission get AC when i use Visual C++ 2013 and get TLE using G++ 4.9 C++11... Why? Probably because slow input/output. | | In fact, it's easy to wrap around | zhangweilst | 1723. Sandro's Book | 4 Jan 2016 15:29 | 1 | It is guaranteed that the most often appeared letter is the right answer. Only one letter is needed. | | Compilation eror | Retag | 1000. A+B Problem | 4 Jan 2016 02:44 | 2 | Пишу на Dev-C++ примет ли мой код? и почему-то пишет Compilation Eror. вот код: # include <iostream> # include <windows.h> using namespace std; int main() { int a, b; cout << "Enter your numbers "; cin >> a >> b; cout << "Answer is " << a+b << endl;
system("pause"); return 0; } Во-первых, лишних надписей вроде enter numbers, answer и тд не нужно — проверяющая программа увидит их и сочтёт за ошибку. Выводить нужно только те данные, которые требуются по условию. cin>>a>>b; cout<<a+b; — этого достаточно. system("pause") тоже не нужен. Отредактируйте и можно снова отправить. Если снова compilation error, попробуйте другие сишные компиляторы, там их куча в списке. И ещё рекомендую прочесть руководство http://acm.timus.ru/help.aspx?topic=judge(и там же есть раздел по c/c++) | | what's wrong? why runtime error (non-zero exit code)? help me! | Nguyen Van Tuan | 1000. A+B Problem | 3 Jan 2016 01:12 | 4 | #include <iostream> using namespace std; int main() { int a,b; cin >>a; cin >>b; cout<<a+b; return 1; } > why runtime error (non-zero exit code)? > return 1; LOL thanks you so muck! your mean is wrong in "return 1;" so display "Compilation error" Every solution send to this page must return 0 as exit code, otherwise you will get "Runtime Error". | | Hint : fermats last theorem | 2MMLoser | 1349. Farm | 2 Jan 2016 15:28 | 4 | search wikipedia for FERMAT'S LAST THEOREM and you will come to know everything about this problem.(1349 Farm) Edited by author 01.11.2011 15:24 I have discovered a truly marvellous proof of this, which this margin is too narrow to contain Thanks you are a saviour. I was applying all my mathematics to get those triplets for n > 2. | | WA 3! | __Andrewy__ | 1684. Jack's Last Word | 2 Jan 2016 14:59 | 1 | WA 3! __Andrewy__ 2 Jan 2016 14:59 const Nmax=1000000; var s:array[0..Nmax-1] of char; z,ans,rans:array[0..Nmax-1] of longint; N,M,i,L,R,last,len:longint; ch:char;
function min(x,y:longint):longint; begin if(x>y) then x:=y; min:=x; end;
procedure Init; begin N:=-1; read(ch); while(ord(ch)>=ord('a'))and(ord(ch)<=ord('z')) do begin inc(N); s[N]:=ch; read(ch); end; readln;
inc(N); M:=0; s[N]:='#'; read(ch); while(ord(ch)>=ord('a'))and(ord(ch)<=ord('z')) do begin inc(N); inc(M); s[N]:=ch; read(ch); end; end;
BEGIN Init; z[0]:=N; L:=0; R:=0;
for i:=1 to N do begin if(i<=R) then z[i]:=min(z[i-l],R-i+1) else z[i]:=0; while(i+z[i]<=N)and(s[i+z[i]]=s[z[i]]) do inc(z[i]); if(i+z[i]-1>R)and(z[i]>0) then begin R:=i+z[i]-1; L:=i; end; end;
len:=0; last:=N; R:=0; i:=N; while(i>=N-M) do begin if(z[i]>=last-i+1) then begin inc(r); ans[r]:=i; rans[r]:=last; inc(len,last-i+1); last:=i-1; end; dec(i); end;
if(len<M) then writeln('Yes') else begin writeln('No'); for i:=r downto 1 do begin for l:=ans[i] to rans[i] do write(s[l]); write(' '); end; end; END. В чём баг хз.Уже сколько пытаюсь сдать-всегда WA3! Решал так:s1 и s2-входные строки,создаю строку s1#s2,вычисляю z-функцию для s=s1#s2,иду с конца строки до символа # и пытаюсь "покрыть" "не покрытые" символы. Если всю строку покрыл,то ответ No,иначе Yes | | why not an all-zero array? | Ade | 2065. Different Sums | 2 Jan 2016 14:11 | 2 | Only one subarray sum, isn't it? At least K different (unique) numbers, read attentively. | | Not working on 7... | Andrew66 | 2035. Another Dress Rehearsal | 2 Jan 2016 13:21 | 2 | I came up with a solution that deals with the problems mentioned in the other topics, but still get wa on test 7 after I tried all tests that I could think of. Why is this? Does anybody know what test 7 is? Thanks in advance! :) Edited by author 13.10.2015 22:03 Remember that X ONLY applies to A and Y ONLY applies to B. For example: 7 5 11 Your answer can be 6 5, but it cant be 5 6. | | tests | async_prince | 1055. Combinations | 2 Jan 2016 09:03 | 2 | tests async_prince 16 Dec 2011 12:31 1 1 0 1 50000 5130 50000 1 2 19 40320 4204 p.s. why time limitation is 2sec? it can be solved very fast using Lucas theorem. Edited by author 16.12.2011 12:47 Your tests are invalid. M < N. So you posted three bad cases. The only correct is 50000 1. | | help me pls! | inmeyoutrust | 1020. Rope | 1 Jan 2016 21:08 | 3 | WA #3 #include <iostream> #include <cmath> #include <map> #include <vector> #include <cmath> #include <stdio.h> #include <iomanip> #include <math.h> using namespace std; int main() { const double PI = acos(-1.); int n; double r; cin >> n >> r;
double x1, y1; cin >> x1 >> y1;
if(n == 1) { cout << fixed << setprecision(2) << r << endl; return 0; }
double vaultx, vaulty; vaultx = x1; vaulty = y1;
double x2, y2; double d; double p = 0.0; for(int i = 0; i < n - 1; i++) { cin >> x2 >> y2;
d = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); p += d;
x1 = x2; y1 = y2; }
p += sqrt(pow(x1 - vaultx, 2) + pow(y1 - vaulty, 2));
p += 2 * PI * r;
cout << fixed << setprecision(2) << p << endl;
return 0; } if(n == 1) { cout << fixed << setprecision(2) << 2 * PI * r << endl; return 0; } | | If you WA on #9 | findslowly | 1084. Goat in the Garden | 1 Jan 2016 17:52 | 5 | Maybe you can try to declare l,r as double not int :) Haha, define like this works, double sideLength = in.nextDouble(); double ropeLength = in.nextDouble(); that's so weired. | | Test #8 : Run-time error; Python script: help me fellas | Neeraj Kumar | 1493. One Step from Happiness | 1 Jan 2016 13:55 | 1 | In a different IDE with all boundary conditions checked, it's working but it shows run-time error at test #8, not sure why. import sys def compute_sum(n): return int(n[0]) + int(n[1]) + int(n[2]) - int(n[3]) - int(n[4]) - int(n[5]) n = input() s2 = 1 s3 = 1 if int(n) == 0 or int(n) == 999999: print ('Yes') sys.exit() s1 = compute_sum(n) if len(str(int(n))) < 6: d = 6 - len(str(int(n))) s2 = compute_sum('0' * d + str(int(n) - 1)) s3 = compute_sum('0' * d + str(int(n) + 1)) else: s2 = compute_sum(str(int(n) - 1)) if len(str(int(n) + 1)) <= 6: s3 = compute_sum(str(int(n) + 1)) if abs(s2) == 0 or abs(s3) == 0: print ("Yes") else: print ("No") |
|
|