| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Python big numbers | TwoEightNine | 1153. Суперкомпьютер | 5 июн 2016 19:43 | 5 |
print(int((((8*int(input())+1)**.5)-1)/2)) why the fuck doesnt it work???? i got wa6, who can help me with tests? Do you know how floating-point numbers work? Hint: use binary search Edited by author 24.10.2014 14:27 10^600 gives "OverflowError: int too large to convert to float" :) You can use Python library "decimal" |
| linkedlist gives wa21, arraylist takes 0.2s for AC | Михаил Аршинов | 1901. Космический лифт | 5 июн 2016 04:55 | 1 |
sort, read from head and tail\ if head+tail>maximum -> add head,tail to the answers (in front),\ otherwise, add head to answers (to the back)\ wow! interesting observation though |
| Must all technologies of a project be used? | Bruce Merry | 2085. Волшебный программист | 4 июн 2016 15:52 | 2 |
When Ivan enters a project, *must* he use all the technologies used in the project, or can he choose to use only a subset of them (so as to avoid using a technology he has already used)? |
| Hello. Could anybody tell me how to solve this problem? (See in) | Safe Bird | 1092. Трансверсаль | 4 июн 2016 12:46 | 8 |
Someone said that it can be solved by Greedy. Just use net flow to catch the largest number of "+". And then so. But they all said that it is a wrong arithmetic. Could you tell me your way to solve it? > Someone said that it can be solved by Greedy. Just use net > flow to catch the largest number of "+". And then so. But > they all said that it is a wrong arithmetic. Could you tell > me your way to solve it? > > Someone said that it can be solved by Greedy. Just use net > > flow to catch the largest number of "+". And then so. But > > they all said that it is a wrong arithmetic. Could you > tell > > me your way to solve it? You can't prove it, because there is a counter-eaxample: 2 +---- +---- +---- +---- +---- Could you tell me what's the meaning of this problem?my english is noot good.The google translation is bad. |
| ac in one go | arun | 1016. Кубик на прогулке | 4 июн 2016 10:38 | 1 |
alot of time in debugging though ! :) |
| Give me some tests please | Ivan Metelev | 2010. Юный гроссмейстер Саша | 2 июн 2016 17:15 | 5 |
I have WA#16, give me some tests please Edited by author 09.11.2014 18:38 Edited by author 09.11.2014 18:35 Edited by author 09.11.2014 18:35 I can poste my bad code, can someone help me? var a, b, n, x, y: int64; begin readln(n, x, y); write('King: '); if n = 1 then writeln(0) else if ((x = 1) and (y = 1)) or ((x = n) and (y = 1)) or ((x = 1) and (y = n)) or ((x = n) and (y = n)) then writeln(3) else if (x = 1) or (y = 1) or (x = n) or (y = n) then writeln(5) else writeln(8); write('Knight: '); if (n = 1) or (n = 2) or ((n = 3) and (x = 2) and (y = 2)) then writeln(0) else if (((y = 1) and (x = 1)) or ((y = n) and (x = n)) or ((y = 1) and (x = n)) or ((y = n) and (x = 1))) or (n = 3) and ((x = 2) or (y = 2)) then writeln(2) else if ((x = 2) and ((y = 1) or (y = n))) or ((x = n - 1) and ((y = 1) or (y = n)) or ((y = 2) and ((x = 1) or (x = n))) or ((Y = N - 1) and ((x = 1) or (x = n)))) then writeln(3) else if (((x >= 3) and (x <= n - 2)) and ((y = 1) or (y = n))) or (((y >= 3) and (y <= n - 2)) and ((x = 1) or (x = n))) or ((x = 2) and ((y = 2) or (y = n - 1)) or ((x = n - 1) and ((y = 2) or (y = n - 1)))) then writeln(4) else if (((x >= 3) and (x <= n - 2)) and ((y = 2) or (y = n - 1))) or (((y >= 3) and (y <= n - 2)) and ((x = 1) or (x = n))) then writeln(6) else writeln(8);
if n = 1 then a := 0 else if (n - x >= x) and (n - x >= n - y) and (n - x >= y) then a := (n - 1) + 2 * (x - 1) else if (x >= n - x) and (x >= n - y) and (x >= y) then a := (n - 1) + 2 * (n - x) else if (y >= x) and (y >= n - y) and (y >= n - x) then a := (n - 1) + 2 * (n - y) else if (n - y >= x) and (n - y >= n - x) and (n - y >= y) then a := (n - 1) + 2 * (y - 1); if n = 1 then b := 0 else b := (n - 1) * 2; writeln('Bishop: ', a); writeln('Rook: ', b); writeln('Queen: ', a + b); end. Edited by author 01.06.2016 11:32 I don't know where is problem in your code. But you can insert in the beginning something like that: if x > (n + 1) div 2 then x := n + 1 - x; if y > (n + 1) div 2 then y := n + 1 - y; and remove all comparisons with n. It will make your code much simpler. A much more simple approach would be creating something like function InBounds(x0, y0, xshift, yshift: longint): boolean; begin inc(x0, xshift); inc(y0, yshift); InBounds:=((x0 >= 1) and (x0 <= N) and (y0 >= 1) and (y0 <= N)); end; This will allow to check king and knight in a much more simple and elegant way. King: res:=-1; for i:=-1 to 1 do for j:=-1 to 1 do if InBounds(x0, y0, i, j) then inc(res); writeln('King: ', res); Knight: res:=0; for i:=1 to 2 do //length before turn for j:=0 to 1 do //sign 1 for k:=0 to 1 do begin //sign 2 if InBounds(x0, y0, (j + j - 1) * i, (k + k - 1) * (3 - i)) then inc(res); end; writeln('Knight: ', res); For rook, it's always N + N - 2, even for N = 1, so there was no need to specifically bring up that case... Queen is rook + bishop, and bishop i'd say is the "hardest" part here, but well, you just take the minimum of squares he can move to in each 4 directions, just be attentive... Good luck! |
| Why do I get Runtime Error for solution in Python 3.4 | SabraO | 1001. Обратный корень | 2 июн 2016 12:46 | 2 |
import sys; import math; class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items) - 1] def size(self): return len(self.items) size = 0 intSize = sys.getsizeof(int()); s = Stack(); while (size<100): line = input(); if (not line.isspace()): values = [int(s) for s in line.split() if s.isdigit()]; size += intSize; for value in values: s.push(math.sqrt(value)); while (s.size()>0): print("%.4f" % (s.pop())); > while (size<100): How did you receive magic number "100"? Shouldn't you read input until EOF? |
| How to implement this with Voronoi diagram | al13n | 1369. Тараканьи бега | 31 май 2016 20:45 | 2 |
Ok, I understand Fortune's algorithm for building Voronoi diagrams. But how to implement answering the nearest point queries? Can it be done without explicitly building full-featured Voronoi diagram and then using another sweeping line on it? I guess, the queries can be answered during building the diagram, without actually building the diagram. But how to generate events "a query point meets parabolic front"? Is it even possible in O(log n)? Edited by author 10.11.2016 18:14 |
| Что не так?! C# | Юрий | 1068. Сумма | 31 май 2016 19:00 | 2 |
using System; namespace Consoleapp { class Program { static void Main(string[] args) { int sum = 0; int len = Convert.ToInt32(Console.ReadLine()); for (int i = 2; i <= len; i++) { sum = sum + i; } Console.WriteLine(sum); } } } Absolute value not exceeding 10000 means the number can be in range -10000..10000. |
| Precision | lxn | 1369. Тараканьи бега | 31 май 2016 18:16 | 1 |
I have figured out that the 6th test contains numbers with 8 digits after the decimal point. Is it the maximum alowed or are there tests with more than 8 digits after decimal point. What tollerance shouled be used to compare distances between points? It it neccessary to do it with no error or is there an accepted tollerane? I have generated several test cases with only 6 digits after decimal point, and doubles doesn't allow to resolve this tests correctly. If there are 8 digits after decimal point and 4 before, it is necessary to store about 24 digits. 1) is is necessary to compare distances between points with no error? 2) What is maximum alowed number of digits after decimal point in input? test cases: 2 999.969732 999.984915 1414.181493 0 1 0 0 >>>>> (999.969732 * 999.969732 + 999.984915 * 999.984915 == 1414.181493 * 1414.181493 == 1999909.295143709049) 2 999.856428 999.897768 1414.039753 0 1 0 0 >>>>> (999.856428 * 999.856428 + 999.897768 * 999.897768 == 1999508.423064301008 < (1414.039753 * 1414.039753 == 1999508.423064301009)) 2 999.725264 999.971561 1413.999196 0 1 0 0 >>>>> (999.725264 * 999.725264 + 999.971561 * 999.971561 == 1999393.726288646417 > (1413.999196 * 1413.999196 == 1999393.726288646416)) Edited by author 31.05.2016 18:21 |
| TEST CASE | GastonFontenla | 1208. Соревнование легендарных команд | 30 май 2016 06:01 | 1 |
Here's the big test case: 18 a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 If you are using bitmask be careful with: *Use long long to store the bitmask. There can be 58 contestant (18*3) as showed above *Be careful with casting in C/C++. I was using the following: #define ll long long void SB(ll &m, ll x) { m = ((m) | (1 <<(x))); } But the (1 << (x)) part auto-cast to int. Hence the overflow The correct should be: #define ll long long void SB(ll &m, ll x) { m = ((m) | (1LL <<(x))); } Hope it help! Edited by author 30.05.2016 06:02 |
| Where is error? test 17 | DSamokhina | 1820. Уральские бифштексы | 29 май 2016 23:59 | 1 |
import java.io.*; import java.util.*; public class t1820 { public static void main(String[] args){ Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); int rez = 2; if (n>k){ if (n % k == 0) { rez = 2*n; } else{ if (n % k > k / 2) { rez = (n/k+1)*2; } else { rez = (n/k-1)*2+3; } } } out.println(rez); out.flush(); } } |
| OLE on test #4 | roman_khapov | 1438. Time Limit Exceeded | 29 май 2016 23:01 | 4 |
Hi I have OLE on #4 test Please, give me some test P.S. Sorry for my english :( i also had tried forward and backward labels, i think my program work correct I had OLE #4, and it turned out to be a minor slip in my code. That is, for commands of type «if smth1 <operator> smth2 goto label, i was searching smth1 and smth2 indices in my variable indices array; label i should have searched in my goto indices array, but i accidentally was searching a label index in variable array too; as a result, it returned 0 (which it returned in case if the needed element was the first one, and if the element wasn't found, which shouldn't be happening). So it jumped to the first label and continued from there. Example: label1: A = 10 print 100 label2: goto label2 Due to a mistake, "label2" has been looked for in variables array, which only had "A" in there. It was not found, it returned 0, it jumped to label1, tons of print commands were executed. After mistake is fixed, "label2" is looked for inside labels array, and correctly returns 1. I can't say for sure you have the very same mistake, but still it is likely just a minor slip like this one. |
| problem in Test6 | Litvinov | 1014. Произведение цифр | 28 май 2016 19:49 | 1 |
if is_test_script: print True if begin_script(10) == 25 else False print True if begin_script(9) == 9 else False print True if begin_script(150) == 556 else False print True if begin_script(11) == -1 else False print True if begin_script(10000000000) == -1 else False print True if begin_script(1000000000) == 555555555888 else False print True if begin_script(167) == -1 else False print True if begin_script(24) == 38 else False print True if begin_script(180) == 566 else False print True if begin_script(360) == 589 else False print True if begin_script(0) == 10 else False print True if begin_script('test') == -1 else False print True if begin_script(1013) == -1 else False print True if begin_script(27) == 39 else False print True if begin_script(1) == 1 else False print True if begin_script(0001) == 1 else False print True if begin_script(45) == 59 else False print True if begin_script(40) == 58 else False print True if begin_script(22) == -1 else False that tests are true Edited by author 29.05.2016 05:08 Edited by author 29.05.2016 05:09 |
| i think you need to add anti-hash tests | shkodlaildar | 1989. Подпалиндромы | 27 май 2016 17:04 | 3 |
Hello admins, please add anti-hash tests for this task. How to solve it without hashes? Actually, u can write double-hashes and easy pass these anti-hash tests. |
| Test 1 is wrong. | umid5566 | 1563. Баяны | 27 май 2016 15:11 | 2 |
|
| This is some Tests to WA#8 and WA#9 | saparboy.batirov@gmail.com | 1892. Утро в Кольцово | 27 май 2016 03:26 | 6 |
WA#:8 4 7 1 10 4 00:00:00 00:00:01 00:00:03 00:00:19 4 00:00:02 00:00:04 00:00:19 00:00:20 ans: 00:00:00 00:00:18 00:00:36 00:00:40 00:00:07 00:00:17 00:00:25 00:00:35 WA#9 1 2 3 1 5 0:0:1 0:0:5 0:0:7 0:0:8 0:0:5 5 0:0:2 0:0:2 0:0:5 0:0:7 0:0:10 ans: 00:00:01 00:00:13 00:00:14 00:00:15 00:00:16 00:00:03 00:00:04 00:00:05 00:00:07 00:00:10 WA#9 1 2 3 1 5 0:0:5 0:0:7 0:0:8 0:0:14 0:0:17 5 0:0:1 0:0:3 0:0:5 0:0:10 0:0:15 ans: 00:00:08 00:00:09 00:00:14 00:00:19 00:00:20 00:00:01 00:00:03 00:00:05 00:00:11 00:00:16 This answers from My ACC program It's seems your answer on first test is wrong. Point is that my AC program answer is 00:00:00 00:00:18 00:00:38 00:00:42 00:00:07 00:00:17 00:00:27 00:00:37 Contrary to what Luckyl said, I get the same result as the original poster on the first test in my accepted program. Your test 2 inconsistentб because "The times in each list are pairwise different and are given in ascending order." 1 2 3 1 5 00:00:01 00:00:05 00:00:07 00:00:08 00:00:09 5 00:00:02 00:00:03 00:00:05 00:00:07 00:00:10 Answer 00:00:01 00:00:13 00:00:14 00:00:15 00:00:16 00:00:03 00:00:04 00:00:05 00:00:07 00:00:10 Edited by author 24.01.2012 22:39 this test help me to pass WA8 input 500 500 500 500 50 09:59:11 09:59:12 09:59:13 09:59:14 09:59:15 09:59:16 09:59:17 09:59:18 09:59:19 09:59:20 09:59:21 09:59:22 09:59:23 09:59:24 09:59:25 09:59:26 09:59:27 09:59:28 09:59:29 09:59:30 09:59:31 09:59:32 09:59:33 09:59:34 09:59:35 09:59:36 09:59:37 09:59:38 09:59:39 09:59:40 09:59:41 09:59:42 09:59:43 09:59:44 09:59:45 09:59:46 09:59:47 09:59:48 09:59:49 09:59:50 09:59:51 09:59:52 09:59:53 09:59:54 09:59:55 09:59:56 09:59:57 09:59:58 09:59:59 10:00:00 50 09:59:11 09:59:12 09:59:13 09:59:14 09:59:15 09:59:16 09:59:17 09:59:18 09:59:19 09:59:20 09:59:21 09:59:22 09:59:23 09:59:24 09:59:25 09:59:26 09:59:27 09:59:28 09:59:29 09:59:30 09:59:31 09:59:32 09:59:33 09:59:34 09:59:35 09:59:36 09:59:37 09:59:38 09:59:39 09:59:40 09:59:41 09:59:42 09:59:43 09:59:44 09:59:45 09:59:46 09:59:47 09:59:48 09:59:49 09:59:50 09:59:51 09:59:52 09:59:53 09:59:54 09:59:55 09:59:56 09:59:57 09:59:58 09:59:59 10:00:00 answer(from Ac program) 16:55:51 17:04:11 17:12:31 17:20:51 17:29:11 17:37:31 17:45:51 17:54:11 18:02:31 18:10:51 18:19:11 18:27:31 18:35:51 18:44:11 18:52:31 19:00:51 19:09:11 19:17:31 19:25:51 19:34:11 19:42:31 19:50:51 19:59:11 20:07:31 20:15:51 20:24:11 20:32:31 20:40:51 20:49:11 20:57:31 21:05:51 21:14:11 21:22:31 21:30:51 21:39:11 21:47:31 21:55:51 22:04:11 22:12:31 22:20:51 22:29:11 22:37:31 22:45:51 22:54:11 23:02:31 23:10:51 23:19:11 23:27:31 23:35:51 23:44:11 09:59:11 10:07:31 10:15:51 10:24:11 10:32:31 10:40:51 10:49:11 10:57:31 11:05:51 11:14:11 11:22:31 11:30:51 11:39:11 11:47:31 11:55:51 12:04:11 12:12:31 12:20:51 12:29:11 12:37:31 12:45:51 12:54:11 13:02:31 13:10:51 13:19:11 13:27:31 13:35:51 13:44:11 13:52:31 14:00:51 14:09:11 14:17:31 14:25:51 14:34:11 14:42:31 14:50:51 14:59:11 15:07:31 15:15:51 15:24:11 15:32:31 15:40:51 15:49:11 15:57:31 16:05:51 16:14:11 16:22:31 16:30:51 16:39:11 16:47:31 My program gives another answers for all these tests. But I got WA#15. Who can help me? |
| Problem 1548 "Sakura and Statistics" has been rejudged | Vladimir Yakovlev (USU) | 1548. Сакура и статистика | 27 май 2016 00:03 | 8 |
A bunch of new tests have been added. 33 of 38 authors lost their AC. A little hint: this problem do has a polynomial solution, and it's not so tricky as you may think. Edited by author 28.01.2016 15:20 spam random @ pray Didn't really expect it to work, especially after such a dramatic rejudge. And i didn't even get to use sorts of «clever» random with GA and mutating solutions. Apparently, most of my WAs were because of inappropriate process of building candidate rectangles, or so i believe... Also, here's a test that helped me, though quite likely it won't be too helpful for anyone else: 7 5 10001 11011 11111 11111 11110 11010 10010 --- 5 1 1 7 1 2 1 6 2 3 1 5 4 2 4 7 4 1 5 4 5 spam random @ pray The hint is clear: there is deterministic polynomial algorithm (~O(s^2)). Some useful tests (for that algorithm): 4 9 010000010 111010111 101111101 000101000 9 --------- 4 4 1100 1110 1111 0111 3 ---- 4 4 1100 1110 0111 0010 3 ---- 5 5 11100 11110 11111 01111 00111 3 ----- 4 3 001 111 011 010 3 --- 4 3 010 111 011 001 3 --- 4 4 0010 1110 0111 0101 4 ---- 4 4 0101 1111 1110 0010 4 ---- 4 3 011 010 110 100 3 --- Oh, good job, and thanks for the tests~ I do have a certain algo in mind actually, but i'm afraid i'll be too lazy to try and code it yet — not until some test that breaks my program is added, haha. Well, and here's another test case then, simple but could be useful. I had a bunch of WAs on 3 and 4 initially; i was building candidate rectangles by expanding them from corners. But then i realized there can be H-like cases, and that horizontal row isn't supported by any corners. 3 5 10001 11111 10001 I do have a certain algo in mind actually, but i'm afraid i'll be too lazy to try and code it yet — not until some test that breaks my program is added, haha. Your smart randomized brute force approach is incredible at my mind. I sure eventually there will be Sakura v2 (something like N=10000 (nonsensible) and M=500) and optimized O(s^2) algorithm became unavoidable. Edited by author 27.05.2016 06:42Edit: affirmative, remove it~ Edited by author 27.05.2016 00:09 Roger that. Removed. Edited by author 27.05.2016 00:11 |
| Just for interest | IlushaMax | 2066. Простое выражение | 25 май 2016 18:45 | 3 |
[code deleted] This code Accepted so A can be 0 or 1; B can be 0 or 1; C can be 0 or 1 in tests. But if we will see on combinatons then there are only 4 combinations (if a<=b<=c) and there are 8 tests as min. The paradox Edited by author 14.03.2016 01:18 Edited by moderator 24.11.2019 13:45 Please do not writeln your code there. > This code Accepted so So no run-time checks if a, b, c are in [0-1] interval. Example: [code deleted] Edited by author 25.05.2016 18:45 Edited by moderator 24.11.2019 13:45 |
| i got Ac use 0.02s | ruwelcome | 1118. Нетривиальные числа | 25 май 2016 14:39 | 5 |
[code deleted] Edited by moderator 19.11.2019 23:41 nuuu.. che skazat nu krasavchik. thanks you , my pro is TLE :) |