Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Run time eror(Stack Overflow)why? | Chowdhury Md. Ishmam Rahman | 1001. Reverse Root | 5 Oct 2017 18:28 | 3 | #include<stdio.h> #include<math.h> #include<stdlib.h> #define SIZE 128*1024 int main() { int i,n=0; long long int num[SIZE],N; printf("enter your aray value:\n"); while(scanf("%lld",&N)!=EOF) { num[n]=N; n++; } for(i=n-1;i>=0;i--){
printf("%0.4lf\n",(double)sqrt(num[i])); } return 0; } ohhh...thanks for your great suggestion. | | who has wa4 | CoolBoy | 1588. Jamaica | 5 Oct 2017 17:13 | 4 | 4th test is: 3 0 0 9999 10000 9998 9999 So double should be used instead of float...When I replaced float with double my code passed this test... And, the answer should be 28283 thats wroung answer for that test ! - you shouldn't add to the sum same distance twice !! ans is 14141 ! No! Right answer is 28283, because the points are not placing on one line. Edited by author 05.10.2017 17:14 Edited by author 05.10.2017 17:14 | | Python Что не так в коде? | FY0u11 | 1001. Reverse Root | 4 Oct 2017 22:17 | 4 | from re import * from math import sqrt result = findall('[0-9]+', input()) result.reverse() for i in result: print('{:.4f}'.format(sqrt(int(i)))) Edited by author 14.03.2017 01:20 For the most tasks WA1 means your program can't even solve sample. Have you tried to run it locally? It's clearly visible it doesn't work. Here's my run: http://ideone.com/T9g8rU There is only 2 numbers in output so your program processed first input line only. Edited by author 17.03.2017 14:35Hey admins! His code works well as my, but it doesn't pass on your side. As the prove look bellow: " with open('/tmp/123.txt', 'r') as f: string = f.read()
from re import * from math import sqrt result = findall('[0-9]+', string) result.reverse() for i in result: print('{:.4f}'.format(sqrt(int(i)))) " Answer " runfile('/home/ant/.config/spyder-py3/temp.py', wdir='/home/ant/.config/spyder-py3') 2297.0716 936297014.1164 0.0000 37.7757 " You have mistakes in comparation analysis on your side. Hi, master8282 please, take a look at rules: В решениях задач запрещается: работа с любыми файлами; ... (Source: http://acm.timus.ru/help.aspx?topic=judge) here is the problem, since your code based on file reading. | | Who had a Wrong Answer in 5 th test ? What mistake may be there ? | Escarabajo | 1369. Cockroach Race | 4 Oct 2017 14:14 | 3 | Who had a Wrong Answer in 5 th test ? What mistake may be there ? Locally you can make straitforward solution M * N and check what line is wrong. as far as I remember test 5 is the case N==0, just output empty line.. | | WA11 - please help | Mescalito | 1577. E-mail | 4 Oct 2017 12:17 | 1 | Could someone provide tests for me? Thank you | | If you have WA13 | shardex | 1145. Rope in the Labyrinth | 2 Oct 2017 22:07 | 1 | Try this test: 4 3 #### #..# #### Answer is 1 :) | | It is very easy to get confused where you should use 'n' and where you should use 'm' | Mahilewets Nikita [BSUIR] | 2108. Oleg and Little Ponies | 30 Sep 2017 20:02 | 1 | | | WA42? | shota | 1635. Mnemonics and Palindromes | 30 Sep 2017 16:48 | 2 | WA42? shota 30 Sep 2017 12:39 Re: WA42? Mahilewets Nikita [BSUIR] 30 Sep 2017 16:48 It is something unique I have had WA20, WA23, TLE32, MLE56 But never WA42 | | wrong answer #8 - solved | Moustafa Shahin | 1785. Lost in Localization | 30 Sep 2017 06:57 | 1 | #include <bits/stdc++.h> using namespace std; int main() {int x; vector <string> myvector (2001); fill (myvector.begin(),myvector.begin()+5,"few"); fill (myvector.begin()+6,myvector.begin()+10,"several"); fill (myvector.begin()+11,myvector.begin()+20,"pack"); fill (myvector.begin()+21,myvector.begin()+50,"lots"); fill (myvector.begin()+51,myvector.begin()+100,"horde"); fill (myvector.begin()+101,myvector.begin()+250,"throng"); fill (myvector.begin()+251,myvector.begin()+500,"swarm"); fill (myvector.begin()+501,myvector.begin()+1000,"zounds"); fill (myvector.begin()+1001,myvector.end(),"legion"); cin>>x; cout<<myvector[x]; return 0; } correct solution: #include <bits/stdc++.h> using namespace std; int main() {int x; vector <string> myvector (2001); fill (myvector.begin(),myvector.begin()+5,"few"); fill (myvector.begin()+5,myvector.begin()+10,"several"); fill (myvector.begin()+10,myvector.begin()+20,"pack"); fill (myvector.begin()+20,myvector.begin()+50,"lots"); fill (myvector.begin()+50,myvector.begin()+100,"horde"); fill (myvector.begin()+100,myvector.begin()+250,"throng"); fill (myvector.begin()+250,myvector.begin()+500,"swarm"); fill (myvector.begin()+500,myvector.begin()+1000,"zounds"); fill (myvector.begin()+1000,myvector.end(),"legion"); cin>>x; cout<<myvector[x]<<endl;; return 0; } Edited by author 30.09.2017 07:20 | | Approach? | Saurav Kumar | 2018. The Debut Album | 30 Sep 2017 02:31 | 5 | I want to know how to approach this question in what direction to think so that i can solve it on my own. Thank you. Problem is tagged with dynamic programming First, think about each possible configuration of the current state when you add next song Second, think about techniques of DP - compression well let x[n] be the number of sequences that finish with 1 and y[n] be the number of sequences that finish with 2 of the length n, x[0] = y[0] = 1, x[1] = y[1] = 1, the recurent formula for this is x[n] = y[n - 1] + y[n - 2] + y[n - 3] + .. + y[n - b] and y[n] = x[n - 1] + x[n - 2] + x[n - 3] + .. + x[n - a], basicly for a sequance of n + 1 you must think of the number of ways that the sequance will finish with 1 or with 2 Edited by author 11.08.2017 04:09 I am sorry but I still didn't understand, why x is dependent on y. Won't Y[] include cases having consecutive A times 1 and moreover won't Y[] Include duplicate cases ? I am sorry but I am new to this so that's why I am asking. well let's approuch one case where your array is finishing with 1 but no more than "a" times in a row, because the 1 array is dependent from array of 2 and array 2 is alwais finishing with 2 it will look like this 12.... that is y[n] = x[n - 1], than 112... that is y[n] = x[n - 1] + x[n - 2], than 111...112.... which is y[n] = x[n] + x[n - 1] + x[n - 2] + ... + x[n - a] and is the same in the second case | | GOOD HINT | Felix_Mate | 1151. Radiobeacons | 29 Sep 2017 21:30 | 1 | Маяки могут находится в 1 точке. P.S. Если считать, что маяки не могут быть в одной точке, то тогда нужно решать паросочетанием (как я в начале и решал), что гораздо сложнее по реализации | | Please help with test #6. | gunfighter | 1348. Goat in the Garden 2 | 29 Sep 2017 09:19 | 3 | I tried different tasks and always got the right answer. My code is very messy I can't understand it after getting AC some months ago So probably if your code is clean and easy to read your approach is fundamentally wrong I mean, maybe there are some corner cases | | WA19 | kitxuli | 1780. Gray Code | 28 Sep 2017 17:05 | 1 | WA19 kitxuli 28 Sep 2017 17:05 | | WA 12 | ramon93i7 | 1881. Long problem statement | 27 Sep 2017 22:27 | 5 | WA 12 ramon93i7 16 Apr 2012 12:32 What's wrong in my code? < #include <stdio.h> #include <string.h> int main() { int i,h,w,n,tmp; int curLen = 0, curNumStr = 0; char s[105]; scanf("%d%d%d\n",&h,&w,&n); for(i = 0; i < n; i ++) { gets(s); //scanf("%s",s); tmp = strlen(s); if(curLen) curLen += 1 + tmp; else curLen += tmp; if(curLen / w){ curNumStr += curLen / w; if(curLen % w) curLen = tmp; else curLen = 0; } } if(curLen) curNumStr ++;
tmp = curNumStr / h; if(curNumStr % h) tmp ++; printf("%d",tmp); return 0; } > What's wrong with my code too? h,w,n=map(int,input().split()) a=[] for i in range(n): a.append(input()) lines=0 pag=0 while len(a)>0: if len(a)!=1: length=-1 while length<w: length+=len(a[0])+1 b=a[0] a.remove(a[0]) if length>w: a.reverse() a.append(b) a.reverse() lines+=1 else: lines+=1 a.remove(a[0])
if lines%h==0: pag=lines//h else: pag=lines//h+1 print(pag)
Edited by author 27.09.2017 21:28 Re: WA 12 Mahilewets Nikita [BSUIR] 27 Sep 2017 22:03 I understand, thanks Edited by author 27.09.2017 22:28 Re: WA 12 Mahilewets Nikita [BSUIR] 27 Sep 2017 22:14 You are removing a[0], not element with index 0 So if there are several elements having the same value as a[0] they would be removed together with a[0] So they would be not processed Also I strongly recommend you not to store the entire input but process data just in time | | WA #18 | Amil Khare | 2069. Hard Rock | 27 Sep 2017 21:37 | 2 | WA #18 Amil Khare 27 Sep 2017 21:11 I got WA at test 18. Any tests for me? Got it fixed just, was using wrong indexing -> for rows used N, however, I had to use M. | | Explanation of the problem Statement & Hint needed | Amil Khare | 1982. Electrification Plan | 27 Sep 2017 17:26 | 10 | Hello, I didn't understand the problem statement correctly. Do cities having power stations need to be connected to each other? The solution can be also having more than 1 connected components( Graphs ), right? Edited by author 21.09.2017 09:28 Edited by author 21.09.2017 09:32 Questions you are asking are not about the statement Questions you are asking are about the solution Oh sorry, my bad! However can you please help me ? I will change the topic of the comment. The first question is maybe OK. It is about the statement. So there is "k cities have stations, the other cities need to be connected..." So we need to connect the other n-k cities Oh, got it ! Thanks a lot :) And second question is really about the solution To understand it pay your attention to fact That there is NO INFORMATION ABOUT ANY GRAPHS in the statement No information about Graphs, you mean that whether it's directed or undirected? Statement doesn't contain the word "graph" So the graph is just a mathematical model used for solving such kind of problems not something from statement Also remember that it is ACM ICPC tradition to write informal statements Statements which need to be formalized Thanks a lot for helping me ! :) | | Any Help/Hint | Amil Khare | 1142. Relations | 27 Sep 2017 15:33 | 5 | Hello, I am not that strong in DP but I have been trying hard to understand the problem. I tried coming up with a solution however got WA. I cannot completely understand the hints given before, PLEASE HELP !!! There are two dp-approaches already described on the webboard So I have accepted with dp I have two dp Stirling numbers of the second kind and factorial Then precalculate answer array I have seen the 2 DP solutions however I still don't understand how do they arrive at the relation? Can you describe in detail if possible, Please ! There are X groups consisting of equal numbers. X=1,2,..n. What does it mean, to put some '<' and '>' signs between them? It is just to define some order relation. Just assign one group as the greatest, another group as the second greatest etc. So we find number of ways to make groups and multiply it by number of ways to make ordering https://ideone.com/00UUdf | | Painful to code | Mahilewets Nikita [BSUIR] | 1122. Game | 25 Sep 2017 01:43 | 6 | My solution is very ugly Maybe yours is beautiful How nice is your solution? How ugly can it be? Just need to use three functions: convert board to 2-byte value, unconvert, modify board by making a move at (x, y). And with those, we just do usual BFS, until 0 or 65535 is reached. Unless of course you're not doing brute force but some smart solution. What? Why? You can't be serious. I'll try to scribble the concept in pascal... type TBoard = array[0..3, 0..3] of shortint; //the board TMod = array[0..2, 0..2] of shortint; //the modifier var md: TMod; ... procedure ModifyBoard(x, y: shortint; var board: TBoard); //x, y are coordinates of our move's center //board links to the board array we're modifying var i, j: shortint; begin for i:=-1 to +1 do for j:=-1 to +1 do if (x + i >= 0) and (x + i <= 3) and (y + j >= 0) and (y + j <= 3) then begin //out of bounds check if md[i + 1, j + 1] > 0 then board[x + i, y + j]:=1 - board[x + i, y + j]; //flipping if spot is marked for that end; end; I guess not more effecient than your bit operations, but definitely easier to read. You can, like, just convert 2-byte state into a full board and convert it back with separate functions if needed. Why? Because I have solved a very similar task Flip game I don't like to solve the same task with the same method twice I see, you weren't serious. Sorry. | | Why WA? (my solution included) So... Simply say what traps are in this problem. PLEASE! | Igor Zubchenok (Belarus SU) | 1167. Bicolored Horses | 24 Sep 2017 19:28 | 5 | const maxH=500; var N,K,q,w,e:longint; H:array[1..maxH] of longint; z:array[1..2,1..maxH,0..2] of longint; x:array[0..1] of longint; begin readln(N,K); for q:=1 to N do readln(h[q]); for q:=1 to K do begin z[2,q,0]:=0; z[2,q,1]:=0; z[2,q,2]:=0; end; z[2,1,h[1]]:=1; for q:=2 to N do begin z[1]:=z[2]; for e:=1 to K do begin z[2,e,0]:=0; z[2,e,1]:=0; z[2,e,2]:=0; end; z[2,1]:=z[1,1]; z[2,1,h[q]]:=z[2,1,h[q]]+1; e:=K; if q<K then e:=q; for w:=2 to e do begin x[0]:=z[1,w,0]; x[1]:=z[1,w,1]; x[h[q]]:=x[h[q]]+1; z[2,w,h[q]]:=1; z[2,w,2]:=z[1,w-1,0]*z[1,w-1,1]+z[1,w-1,2]; if z[2,w,2]>z[1,w,2]+x[0]*x[1] then begin z[2,w,0]:=x[0]; z[2,w,1]:=x[1]; z[2,w,2]:=z[1,w,2]; end; end; end; writeln(z[2,K,0]*z[2,K,1]+z[2,K,2]); end. Could you give me a test on which my solution gives wrong answer? Why not ? :"> I have answers to all your questions :) 18 Dec 2001 23:24 Isn't the correct answer 4? 7 2 1 1 0 0 1 1 1 | | дорогие пользователи и авторы | Borisov Sergey | 1919. Titan Ruins: Transformation of Cylinders | 22 Sep 2017 15:59 | 7 | ответьте на вопрос: допустим есть цилиндр с размеромами: 1 на 1000 и отверсие в стене размером 2 на 4, можно ли нарезать мелкими лоскутками цилиндр на размеры 1 на 2, таких отрезков понадобиться 4 штуки, подобный ход удовлетворяеет поставленной задаче ? The sample input shows that 234 3456 is "too small" to cover 314 x 314. а в чём тогда моя ошибка ? Никак не могу пройти тест 4. В отсутствии пространственного воображения. Вы хоть намекните в чем смысл правильного решения, а то мне эта задача спать не даёт, хотя бы вышлите мне тест 4 по возможности as i understand u can rotate cylinder почти правильно сказал предыдущий автор. нужно поворачивать боковую поверхность вокруг центроида, и если её площадь "захлёстывает" прямоугольное отверстие, тогда "Block the hole" Edited by author 22.09.2017 16:36 |
|
|