Common BoardI tried test 1 given in task on my computer and got the same answer. But i get WA #1 wwhen submit try to locate the centre of the diameter of the tree ! O(N) My programm passes all tests from forum, but i still got WA 10. Have anybody some more tricky tests? ADMINSTRATOR HELP PLEASE !!!!!!!!!!!! IT'S MY COD var a:array [1..20010] of char; i,j,k,n,w:integer; r:char; s:string; f:boolean; g:text; t:integer; procedure solve; label 1; var e:integer; begin f:=false; t:=0; for k:=1 to n+i do if (a[k]<>a[n+i-k+1]) then goto 1; f:=true; 1: end; {IMPORTANT PART} Begin assign(g,'input.txt'); reset(g); while not eof(g) do begin readln(g,s); n:=0; for i:=1 to length(s) do begin n:=n+1; a[n]:=s[i]; end; i:=0; repeat solve; if not(f) then begin i:=i+1; for j:=n+i downto n+1 do begin a[j]:=a[j-1]; end; a[n+1]:=a[i]; solve; end; until f; end; // close(g); for j:=1 to n+i do write(a[j]); readln;readln; end. REAL MADRID LUCK THE BEST CLUB Me too!!! program Ural1354; var s:string; a,b,l:longint; begin readln(s); l:=length(s); a:=1; while a<l do begin if s[a]<>s[l] then begin s:=s+' '; for b:=length(s) downto l+2 do s[b]:=s[b-1]; inc(l); s[l]:=s[a]; end; inc(a);dec(l); end; writeln(s); end. You are to find a nonempty word S2 if the input is palindrome... Test#4 abaabaaba ans: abaabaaba //for WA4, because S2 must be not empty! abaabaabaaba //for AC Edited by author 25.11.2011 17:57 I have the same answer, but still get WA4. What the problem? That's not the answer my friend. This is correct: abaabaaba abaababaaba As you see, your solution add three characters. Mine add only two. Greetings! nope, you should print S1 S2, as you see in your answer there is not clearly S1 There are mistake in statement may be. Difference between ._. ._. ..| and ._| is 1 |_. |_. Difference between ._. ._. ..| and |.| is 2 (the second example, the second number) |_. |_| My program write '02:05' except '00:05' like in example and I have wrong answer. Can someone help me? Edited by author 04.06.2016 15:30 Of course only after the end of contest For this task, pay attention to last few sentences. >>Each subsequent value must be strictly less than the preceding one.<< and >>If several answers exist, output any of them. It is guaranteed that there is at least one consistent sequence.<< Thanks a lot! I forgot that 1 test can be not like in statement. And I'll fix my mistake. Edited by author 05.06.2016 15:30 Edited by author 05.06.2016 15:27 Edited by author 07.06.2016 16:45 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" 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 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)? 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. alot of time in debugging though ! :) 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! 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? 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 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. 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 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 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(); } } 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. 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 |
|