|
|
Common BoardI tested for a long time and tried to understand why the thymus mockingly shows me such a mocking number, it's all because of the portals, it's just impossible there, I got so confused in them that I didn't understand how my code worked, in general, how to avoid such a problem. add all sorts of checks near the portals, which is right wherever there are portals, just destroy these portals completely, absolutely dont add negative numbers to answer i think its something like this 2 ab\df\fd df\df ab df fd df df fd Сама задача конечно же довольно простая. Решив ее несколькими способами я каждый раз упирался в превышение объема допустимой памяти на 11 тесте. Соответственно львиная доля времени ушла на осознание того, что же именно потребляет память и на устранение этого узкого места. Как можно было догадаться, память жрали Строки. Я убрал использование string отовсюду кроме считывания данных из консоли. Хранение данных реализовано через два массива int. Для разбора ввода и для вывода ответов в консоль использовались массивы int и char. Вообще, это одна из тех задач, которые отлично иллюстрируют проблему, описанную в FAQ "Как писать решения на C#": "В некоторых задачах потребуется собственная быстрая реализация разбора входных данных и форматирования выходных". Только здесь проблема не в скорости, а в памяти. somebody faced this problem? somebody has a test data? Try this 4 8 1 8 8 should give 1 4 8 8 1 8 also should give 1 if time of djek ravno time of this people so, this is crash i just draw its in paint and use some kinematick formulas and solve it by that These two tests helped we find my bugs. Test 2 1 3 0 2 1 2 The answer is 4. Test 3 10 20 30 1 29 3 1 2 3 2 1 2 The answer is 29. Hope it will help you too. Indeed helpful. You may buy more taps than you need. if you use the two-pointer method, then you have problems with the left pointer N =int(input()) Nl = [] for i in range(N): Nl.append(int(input()))
M = int(input()) Ml = [] for j in range(M): Ml.append(int(input()))
answerl = [] Nl = set(Nl) Nl = list(Nl) Nl.sort() for ni in Nl: for mi in Ml: if mi == ni: answerl.append(mi) else: continue
print(len(answerl)) #include <stdio.h> int main(){ int a, b, c; scanf("%d", &a); b=12-a; if(b*45<=240){ printf("Yes"); } else{ printf("No"); } return 0; } Why if u used min max things and O(n) algorithm. WHEN u have found the point where two shortest paths converge. You need to save distance from this point to r AND when u do MAX(the point,your new path) u need also do min(the point, very old distance in this point). n = int(input()) k=int(input()) n=n*2 if n % k ==0: print(n/k) else: a=int(n/k)+1 print(a) I can't find my mistake. It keep telling me "Runtime error" the "only" input line contains... Help with wa48 use long long instead double Why wa48 or wa49? Edited by author 06.10.2017 11:52 use long long instead double program de; var a,b:array[-1400..1400] of integer; a1,b1:array[1..2800] of integer; i,j,n,max_a,max_b:integer; ch:char; procedure diog; begin if ch='s' then begin b[i-j]:=0; inc(a[i-j]); if a[i-j]>max_a then max_a:=a[i-j]; end else begin a[i-j]:=0; inc(b[i-j]); if b[i-j]>max_b then max_b:=b[i-j]; end; end; procedure diogobrat; begin if ch='s' then begin b1[i+j]:=0; inc(a1[i+j]); if a1[i+j]>max_a then max_a:=a1[i+j]; end else begin a1[i+j]:=0; inc(b1[i+j]); if b1[i+j]>max_b then max_b:=b1[i+j]; end; end; procedure vivod; begin if max_a=max_b then begin writeln('?'); writeln(max_a); end else if max_a<max_b then begin writeln('S'); writeln(max_b); end else begin writeln('s'); writeln(max_a); end; end; begin { assign(input,'c:\test.txt'); reset(input); } readln(n); for i:=1 to n do begin for j:=1 to n do begin read(ch); diog; diogobrat; end; readln; end; vivod; end. There is test where your program wrongs: 5 sSSSS SSsss ssSSS sSSss sSSSS Your program outputs ? 3 but real answer is obvious S 4 Good luck! I thought what to consider it is necessary only on a diagonal. Thanks, now I have AC. Exactly! Do NOT forget to consider vertical and horizontal arrays. Thank you for this test and thanks to my friend Agabek. I got AC now. Please anyone help I had the same mistake. But I used long long and it went away try this test 3 2 4 1 5 3 5 Isn't it 2 1 2 ? Why not? It is right.... I failed in #8 as well... Look at this: We assume, that one segment is inside another, if the two segments are different, the first one is fully contained in the second one, and their endpoints do not coincide. Pay attention to this: and their endpoints do not coincide. It means 3 4 and 4 4 coincide too! try this test : 3 -3 -2 1 5 2 4 Answer: 2 3 2 try this 8 1 10 2 3 4 5 6 7 8 9 20 30 21 29 22 28 answer 3 8 7 6 Another test: .in 3 3 5 3 4 4 5 .out 1 1 or 1 2 or 1 3 This is a helpful test for dfs-like algo. |
|
|