Common Boardn = 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. bonnon Answer b onno n Edited by author 27.10.2022 10:18 Edited by author 27.10.2022 10:19 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" My program got WA8 all the time. I have added next string to my program if(n>50) vector<long> xxx(1000000); and it got AC after that!!! Variable "xxx" never uses in my code! If i delete this line it got WA8!!!! Please, send your program to my e-mail hi. I have sent you my program about an week ago. So what was the problem? Can you send your solution for me:) I'll try to help also I guarantee that I'll help with any of my solved problems be shure I'll not cheat you;) Dear admin, I'm also facing problem on WA-8. Although the guide page says that "the input data of this test case is not available, the solution author should find the cause of the error on their own", I have no idea on what error my program has. So I'm seeking for your help, can I contact you using email? -200 -5 0 200 -5 0 0 200 0 answer should be 16707.55 (> pi*r*r/2), not 14708.38 (my AC program) короче сам голову ломал, там переменные в 1 строку вводить надо может кто то также ошибся Edited by author 17.10.2022 09:55 Edited by author 17.10.2022 09:55 I don't know why there were so many submitted O(n^2) DP solutions. Here is a simple formula for this problem: answer = n - (yes + yes*(yes-1) + no*(no-1))/n, where yes = s-2*n and no = n-yes are the total numbers of occurrences of corresponding strings in answer.txt. You can easily derive this if you try to think of probability of the same verdict for two arbitrary consecutive tests. Why this formula is right? I solved problem by DP, but i can't prove this formula. For any test, the probability to answer correctly is: the probability that the test is the first test and the answer on that test is "yes" plus the probability that the answer is on that test is "yes" and the answer on the previous test is also "yes" plus the probability that the answer on that test is "no" and the answer on previous test is also "no" That is: p=(1/n) *yes/n + (yes/n)*((yes-1)/n) + (no/n)*((no-1)/n) The probability to fail the test is: q=1-p There are n tests, so the expected count is: ans=n*q=n-(yes*yes+no*(no-1))/n This is so clear. Thank you. Yes, that is. It must be true. This is also a good manner. What is the mistake? n = int(input()) a = [] for i in range(1, n+1): if n % i == 0: a.append(i) if n == 1: print("1") exit(0) if n == 0: print("10") exit() if len(a) > 2: for i in range(len(a) - 1): if a[i] * a[i + 1] == n or a[i]*a[i] == n: if a[i] * a[i + 1] == n: s = "".join(sorted(str(a[i])+str(a[i+1]))) print(s) else: print(a[i], a[i], sep="") else: print("-1") # Alternative Solution Valentine is a veteran of programming contests and he's been working in the program committee for many years. He is very busy this week: the bike is under repair, some problems with Indian colleagues have to be solved, and five student groups are to be examined in philosophical problems of mathematics at the university. To crown it all, the new chairman of the program committee asked Valentine to write an alternative solution for one of the problems of the forthcoming contest. Valentine was so busy that he had no time to read the problem statement. He only glanced at the output format and understood that it was required to output either `YES`, or `NO`. Fortunately, Valentine was well acquainted with the testing system used in the contest. The system successively runs a solution on all tests of a problem, and for each test the checking process goes as follows. The input is copied to the file input.txt. Then the solution is launched. It reads the input from the file input.txt and writes the result to the file output.txt. When it finishes, the correct answer is copied to the file answer.txt. If the contents of the files answer.txt and output.txt match, the test is assumed to be passed; otherwise, the test is not passed. Valentine decided to write a program that would operate as follows. If the folder containing the program doesn't contain the file answer.txt (i.e. the program is run on the first test), then the program outputs `YES`. Otherwise, the program outputs the contents of the file answer.txt. Valentine plans to tell the chairman of the program committee that there is a nontrivial mistake in his program, and this mistake, fortunately, shows itself when the program is run on the excellent hard tests prepared by the author of the problem. However, first Valentine has to estimate the number of tests that his solution won't pass. Valentine doesn't have access to the tests, but he knows the number of tests and the total size of the files with answers. He also knows that the size of the file with the answer `YES` is 3 bytes, the size of the file with the answer `NO` is $2$ bytes, and all the variants of the order of tests are equally probable. Help Valentine to calculate the average number of tests that his solution won't pass. ## Input The only line contains two integers $n$ and $s$ ($1 \le n \le 5000$; $2n \le s \le 3n$) which are the number of tests and the total size of the files with answers, respectively. The numbers are separated with a space. ## Output Output the average number of tests that Valentine's solution won't pass, accurate to $10^{-5}$. ## Sample ### input ``` 3 7 ``` ### output ``` 2.0000000 ``` Let a=s-2n,b=3n-s. Then the answer is (2ab+b)/n. Try it, you won't regret it! I saw no one comment, so I would comment myself. This is so marvelous an editorial. A thousand thanks to the author(me)! :-) Still no one commenting, I guess I'm not a celebrety. :-( Sorry for my spelling. Can I get 50 comments? Yes, if I do this forever. You should write it in markdown: Let $a = s - 2n$, $b = 3n - s$. Then the answer is $\frac{2ab+b}{n}$. Try it, you won't regret it! Try it, you won't regret it! Edited by author 15.10.2022 12:35 A million thanks to remmymilkyway, the first person other than me to comment!!!!!!!!!!!!1 |
|