Common Board| Show all threads Hide all threads Show all messages Hide all messages | | 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 | | WA 11 | Shili_Xu | 1773. Metro to Every Home | 22 Sep 2017 08:06 | 1 | WA 11 Shili_Xu 22 Sep 2017 08:06 Dear anyone, show me the 11th test case please! | | Help! В чём проблема? Java | qNkkkk | 1001. Reverse Root | 20 Sep 2017 21:57 | 2 | import java.util.Scanner; public class JavaApplication12 {
public static void main(String[] args) {
double x,k; int a; double y =Math.pow(10,18);
System.out.println("Сколько хотите ввести чисел ? "); Scanner sc = new Scanner(System.in); a = sc.nextInt(); int arr[] = new int[a]; for(int j=0;j<a;j++) { do { arr[j] =(int) sc.nextLong(); } while (arr[j]<0 || arr[j]>y);
} for(int i=a-1;i>=0;i--) { k = Math.sqrt(arr[i]); System.out.println(k); }
} } >Сколько хотите ввести чисел? ))))) | | Hint : Dp on trees | Pradyumna Bang | 1039. Anniversary Party | 20 Sep 2017 15:24 | 2 | where do you fill your dp? is it in dfs? I did that but it has a problem:( Edited by author 20.09.2017 15:25 Edited by author 20.09.2017 15:25 | | Can you explain this test? | Khujamurod | 1022. Genealogical Tree | 19 Sep 2017 16:00 | 11 | Help! I dont understand that problem. test: 3 0 1 0 0 can you explain which one is right ? 2 1 3 or 3 2 1 In addition I get WA6 and this is my code : /* #include <stdio.h> #define maxn 105 int vp[maxn], pv[maxn]; int main() {
int n, x, y; scanf("%d", &n); for(int i = 1; i <= n; i ++) { vp[i] = i; pv[i] = i; } for (int i = 1; i <= n; i ++) { int min = vp[i]; while(1) { scanf("%d", &x); if(x == 0) break; if(vp[x] < min) min = vp[x]; } for (int j = i - 1; j >= min; j --) { pv[j + 1] = pv[j]; vp[pv[j + 1]] = j + 1; } pv[min] = i; vp[i] = min; } for (int i = 1; i <= n; i ++) { printf("%d ", pv[i]); } return 0; } */ I don't understand what your code does. Probably intended solution uses an algorithm calling "topological sorting". (My solution uses it too). By definition, topological sorting solves the task 1022. Edited by author 14.07.2017 12:44 Yeah you are right. It is not an algorithm. It is just an idea but i think this idea should accept! Yes, I made a mistake. Correct would be something like. Intended solution is a program that calculates topological sort of vertices of a graph built from input data using some well-known algorithm for calculating topological sorting In topological sorting, you are doing depth first search and memorize vertices when you leave them. When all the vertices are considered, you have memorized vertices in reversed topological sorted order. Edited by author 14.07.2017 12:45 void dfs(int nd) { for(int to : adj[nd]) if(!used[to]) dfs(to); used[nd] = true; //switch the node into visited ans.push_back(nd); //put the node to array } Edited by author 19.09.2017 16:03 My AC program gives "3 2 1". So, probably "3 2 1" is the right answer. If several sequences satisfy the conditions of the problem, you are to write to the standard output any of them!!! ;) ;/ You should all do just DFS!(How? Just enter any node and check its adjacents were visited. So that enter node which was not visited before. Finally, put this node to array after checking and reverse the answer array)! Edited by author 19.09.2017 16:04 | | to admins | Combatcook | 2082. Poker | 19 Sep 2017 14:28 | 5 | Несколько вопросов по условию задачи: 1) В условии сказано: "В третьей строке расположена текущая улица — preflop, flop, turn или river." "Действиями могут быть ходы игроков или переход на следующую улицу (dealing)." Но в примерах 2 и 3 текущая улица - flop, переход тоже осуществляется на flop... Где ошибка - в примере или в условии (или я что-то не так понял..)? 2) Возможна ли такая ситуация, что у игрока не хватает денег поставить анте или блайнд (то есть ему приходится для этого идти ва-банк)? Если да, то может ли игрок принимать участие в дальнейших торгах? Заранее спасибо за пояснения. 1) There're all history of players' turns in the test starting from preflop. So if, for example, the current street is river - it always should be 'dealing flop', 'dealing turn' and 'dealing river' strings, inside the input or inside the output, but never inside both of them. 2) "If player calls all-in, that action is presented in the input as raise, bet or call" The situation you described is possible. The player who called all-in goes in a "freeze" state - he can't do anything. It's like he folded. Thank you! But that phrase is not clear to me: "inside the input or inside the output, but never inside both of them". So, if we have that current street is river, why can't 'dealing flop' and 'dealing turn' be inside the input, and 'dealing river' inside the output respectivly? I mean, each of these strings appear exactly once. One of possible situations is what you described. 1.on test 15, if someone have not enough money to bet ante Does he go all_in and get folded? 2. when bot get folded , is output over and doesn't include this line? Edited by author 19.09.2017 14:29 | | To admins: please, add tests! | Dmitri Belous | 1294. Mars Satellites | 19 Sep 2017 13:56 | 3 | My simple wrong program skips necessary mathematical checks, but it got AC. 1 20 5 5 Answer: Impossible. (Wrong solution skipped the check of cos(∠DAC) bounds; a cosinus must be from -1 to 1) 5 7 4 7 Answer: Impossible. (Wrong solution skipped the check of the order of satelites; the test case is from the task subscription, I've just changed the positions of A and B satelites). Unfortunately both tests are incorrect. "Impossible" means only "ambiguous" in this problem. | | Wrong answer help me pls Pascal | Levchuk | 2066. Simple Expression | 18 Sep 2017 19:22 | 1 | var a,b,c,s: longint; begin readln(a,b,c); if (a > b) or (a > c) then if (b > c) then s:= c - a * b else s:= b - a * c; if (b > a) or (b > c) then if a > c then s:= c - a * b else s:= a - b * c; if (c > a) or (c > b) then if a > b then s:= b - a * c else s:=a - b * c; writeln(s); end. | | WA#18 | Bogolyubkiy | 1227. Rally Championship | 17 Sep 2017 19:32 | 2 | WA#18 Bogolyubkiy 4 May 2010 19:20 Can you suggest an example for this test? 4 3 40 1 2 10 2 3 20 2 4 20 Right answer: YES | | Hint | Amil Khare | 1777. Anindilyakwa | 17 Sep 2017 19:27 | 1 | Hint Amil Khare 17 Sep 2017 19:27 Hello, So initially I thought there might some cases like there are in questions regarding divisors, range, odd, even etc. However, there wasn't any such case. I tried simulating the above problem for a = 1-20, b =1-20, c= 1-20. The maximum possible answer was 3 and minimum was 3 so I was sure simulation was enough. I tried my best to derive some relation but was unable to do so. So in this way, you could think about solving the problem and just simulate the whole process to solve it. | | For WA#9 | Dmitri Belous | 1116. Piecewise Constant Function | 17 Sep 2017 16:16 | 1 | For WA#9 Dmitri Belous 17 Sep 2017 16:16 The test below helped me on WA#9. 2 0 5 12 5 10 13 1 3 7 21 Right answer: 2 0 3 12 7 10 13. | | Wrong answer (C) | alexanius | 1001. Reverse Root | 17 Sep 2017 04:33 | 4 | The tests from example and few other are ok, but it gets wrong answer in test1. #include <math.h> #include <stdio.h> #define SIZE (256 * 1024) / sizeof(long long) long long int n[SIZE + 1]; int main(void) { int s = 0, l; do{ l = scanf("%lld", &(n[s])); s++; } while(l != EOF); s -= 2; for(;s >= 0; s--) printf("%.4Lf\n", sqrtl(n[s])); return 0; } The problem here is that system accepts printf("%.4f\n", sqrt(n[s])); but does not accept printf("%.4Lf\n", sqrtl(n[s])); It is a bit strange because the second version is more precise. It would be great if some one showed a false test for the second variant. Maybe you were printing something like 1.23456e-789? No, L is a modifier for extended data type. To be sure I tried the following variant: printf("%.4Lf\n", sqrt((double)n[s])); and it passed. So the only problem is difference between sqrt and sqrtl. To admins: I think that at least one of the tests gives different values when using sqrt and sqrtl. And more precise variant fails. Please check my guess, I think that using of both functions should be valid. |
|
|