Это пешки, а не дамки, поэтому они могут рубить только соседние фишки Не слушайте тех кто пишет что убрал проверку за границы и зашла и все в таком духе. Возможно у вас такая же ошибка как и у меня, а то есть когда ввели новые координаты я проверял только то что может ли эту новую координату кто то ударить, а надо было еще проверить что может ли новая координа ударить кого то из врагов 1)Если игрок1 сделал ход b2,а игрок2 сделал ход a1, то в таком случае игрок2 не должен проиграть? 2) При ходах: b2 a1 h8 ... правильный ответ должен быть 3? Так как после хода h8 пешка на a1 может перепрыгнуть пешку на b2. Не могу найти ошибочный тест (На 2 тесте неверный ответ) So many posts here that the problem statement is incomplete or that the tests are wrong. I hereby announce that there is ABSOLUTELY nothing wrong with this problem. Just solve it straightforwardly and you'll get AC. If you don't get AC, it means that you have solved the problem incorrectly! There is no input with less or more than 32 moves, no input where there are white cells, no input with cells that are out of bounds, no input with same cell twice, blah blah blah ans so on. So stop the hysteria, read the statement one more time, and solve this simple problem, and don't scare/discourage other people from solving it(I myself, frankly, after reading all your posts, didn't even want to start solving it, because I thought this could be one of those dirty problems with incomplete statement or whatever). Thank you. This is correct. Just we need to consider all the cases with boundary conditions. Edited by author 08.04.2014 13:31 Edited by author 08.04.2014 13:32 Edited by author 23.04.2009 05:04 try this test: input: a1 h8 a3 h6 a5 h4 a7 h2 b2 g7 b4 g5 b6 g3 b8 g1 c1 f8 c3 f6 c5 f4 c7 f2 d2 e7 d4 e5 d6 e3 d8 e1 output: Draw first my code write 31. program ural1334; const dx:array[1..8]of shortint=(-1,-1,-1,0,1,1,1,0); dy:array[1..8]of shortint=(-1,0,1,1,1,0,-1,-1); var a:array[0..9,0..9]of byte; i,x,y,d:byte; c:char; begin fillchar(a,sizeof(a),2); for i:=1 to 32 do begin readln(c,y); x:=ord(c)-96; for d:=1 to 8 do if a[x+dx[d],y+dy[d]]+i and 1=1 then begin writeln(i); halt; end; a[x,y]:=i and 1; end; writeln('Draw'); end. I have submitted for about 100 times with my (another) ID and finally get AC. Here I want to say something about the problem. 1. Is this problem easy? Yes, very much. I think this problem could be regarded as 'PROBLEM FOR BEGINNERS'. BTW, I think after reading my note, EVERYONE will be able to solve the problem. 2. What does the chessboard look like? The chessboard is a common 8*8-board. The coordinates are marked with a~h(lowercase) and 1~8. 'a1' is a black cell. 3. How many players are there? EXACTLY TWO. 4. Are all the checkers put on the black cell of the board? Yes. 5. What does it mean by JUMPING OVER? B could JUMPING OVER A, if A is at one of the four corners of B. (Use coordinates, (-1, -1), (-1, 1), (1, -1), (1, 1)). Do NOT think there are far-away jumpings, such as 'a1' jumps over 'c3'. 6. It says that, after jumping over, the checker mustn't fall over the board, is it right? Yes! 7. It says that, after jumping over, the checker must be located at a FREE cell. What does FREE mean? It means EMPTY cell, a cell without ANYTHING (and, within the board boundary). 8. What does it mean by "ONE OF THE OPPONENTS" gets the opportunity? Let us call the two players Alice and Bob. After Bob, for example, makes a move, if one of Alice's checker could fell one of Bob's checker, OR one of Bob's checker could fell one of Alice's checker, we think that "ONE OF THE OPPONENTS" have the opportunity. WARNING: In BOTH cases above, it was Bob who will lose the game at once. 9. Are there mistakes in the test data? No. There are no checkers put outside the board (such as a9 or g3), and no two checkers at the same place. 10. Could the output be '32'? Yes. You can construct the case yourself. 11. Could the output be 'Draw'? Yes. You can construct the case yourself. 12. Why did the author of this note use nearly 100 times to get AC? Maybe something was wrong with him. Don't be like him :) At last, we take a look at some cases: (1) b2 a1 (Some other 30 moves) Answer should be 2: Although 'a1' could not be felled by 'b2' (Question 6), but 'b2' could be felled by 'a1', so the second player loses at once (Question 8). (2) a1 d4 b2 c3 (Some other 28 moves) In this case, we could NOT judge the result with the first 4 moves (Questions 7 & 8). (3) a1 h8 a3 h6 a5 h4 a7 h2 b2 g7 b4 g5 b6 g3 b8 g1 c1 f8 c3 f6 c5 f4 c7 f2 d2 e7 d4 e5 d6 e3 d8 e1 It's a 'Draw' game (Questions 6, 7 & 8). So, Good luck for EVERYONE. Edited by author 16.09.2012 22:37 may b something was wrong previously. now it is correct. can't fall over boundary. must jump to empty cell. and only black cells. however, u must check - new checker may attack or be attacked :P Yes, it is somehow strange but if one of players put checker and this checker can attack the checker of another colour, so the game is stopped with the fool (!) of this player. Naturally, if this put checker could be attacked the end is the same. WA#24 is the case,in which answer is Draw ! Just check all diagonals and try to find one of these four sequences: 1. white-black-empty 2. black-white-empty 3. empty-white-black 4. empty-black-white And you'll get AC. Nothing hard... I think now all test where op win cose he may eat last figure but !!! add test where last fugure eat some other for example : b2 a1 e5 d4 some other 28 move in this test out must 2 but many algo return 4 :) There mustn't be 2(I think) there must be 3 in test 2 checkers go out of desk in test 6 I don't know but something terrible:) solution without common sense got AC but you add some test with common sense and now I don't know how to get AC on this problem we give you some tests... OK you added them? but you don't delete wrong existing tests Test #2 and test #6 are correct. very strange conditions... Edited by author 23.04.2009 05:01 var m:array[0..9,0..9] of shortint; st:string; i,c,x,y,k:integer; begin while not eof do begin readln(st); inc(k); case st[1] of 'a': x:=1; 'b': x:=2; 'c': x:=3; 'd': x:=4; 'e': x:=5; 'f': x:=6; 'g': x:=7; 'h': x:=8; end; delete(st,1,1); val(st,y,c); m[x,y] := k mod 2 +1; if ((m[x+1,y+1]=3-m[x,y]) and (m[x-1,y-1]=0) or (m[x-1,y-1]=3-m[x,y]) and (m[x+1,y+1]=0) or (m[x-1,y+1]=3-m[x,y]) and (m[x+1,y-1]=0) or (m[x+1,y-1]=3-m[x,y]) and (m[x+1,y-1]=0)) then begin if k<=32 then write(k); halt; end; end; write('Draw'); end. P.S. I think the name of the problem "Stochastic chechers" is much more better than "checkers". I know AC solution that answers 4 for sequence starting from the following: b2 h8 c3 a1 It is wrong. Neither black a1 can "jump over" white b2 (because c3 is not free) nor white b2 can "jump over" black a1 (because there is no cell behind a1). I even know AC solution that answers 4 for input starting a1 d4 b2 c3 It is wrong because b2 cannot jump over c3 (d4 is not empty) and c3 cannot jump over b2 (a1 is not empty). В стРоках с нечетным номером ходы белых, в строках с четным номером – черных. Edited by author 08.07.2008 03:39 Stupid, stupid task with wrong, wrong tests! Why checkers can go out of a desc, why nobody sad that there could be move after the last 32'th step? Why just not to tell everyone rules of the game in the text of the problem? Edited by author 08.03.2007 21:35 Problem statement says that: "Checker A may be felled by checker B if checkers A and B are of different color and a cell, on which B comes after "jumping over" checker A, is free" But look at this test: b2 b8 b6 d8 c3 f8 c5 h8 e3 h6 e5 h4 f2 h2 f6 d4 Output must be "Draw" because there is no empty space for checker in d4 (last one) to move. But my AC program outputs 16 You should change tests or correct problem statement. There are allways 32 moves, your test is incorrect don't consider the boundary when jump don't consider whether the jumping aid cell is free... the describe and data is wrong... I read all the topics in the forum, but it doesn't seem serious to me the tests to be wrong - I thing, the problem is in me...So here is my program - if anyone has a little time, could have a look at it - Wrong answer on test2.... #include <iostream.h> #include <stdio.h> int a[8][8],i,j; int wins1(char x,char y, int id) { if ((x <= 'a') || (x >= 'h') || (y <= '1') || (y >= '8')) return 0; if (a[x-'a'-1][y-'1'-1]+a[x-'a'+1][y-'1'+1]==2*(1-id)+1) return 1; if (a[x-'a'-1][y-'1'+1]+a[x-'a'+1][y-'1'-1]==2*(1-id)+1) return 1; return 0; } int wins(char x,char y, int id) { if (x < 'a' || x > 'h' || y < '1' || y > '8') return 0; if ((x >= 'c') && (y >= '3') && (a[x-'a'-1][y-'1'-1]==2*(1-id)+1) && (a[x-'a'-2][y-'1'-2]==0)) return 1; if ((x >= 'c') && (y <= '6') && (a[x-'a'-1][y-'1'+1]==2*(1-id)+1) && (a[x-'a'-2][y-'1'+2]==0)) return 1; if ((x <= 'f') && (y >= '3') && (a[x-'a'+1][y-'1'-1]==2*(1-id)+1) && (a[x-'a'+2][y-'1'-2]==0)) return 1; if ((x <= 'f') && (y <= '6') && (a[x-'a'+1][y-'1'+1]==2*(1-id)+1) && (a[x-'a'+2][y-'1'+2]==0)) return 1; return 0; } int main() { char s[222], p[222]; p[0] = 'a'-1; p[1] = '1'-1; for(i = 0; i < 8; i++) for (j = 0; j < 8; j++) a[i][j] = 0; for (i = 0; i < 32; i++) { gets(s); if (s[0] >='A' && s[0] <= 'Z') s[0] = s[0]-'A'+'a'; a[s[0]-'a'][s[1]-'1'] = 2*(i%2)+1; if (wins(p[0],p[1],1-(i%2)) == 1) { cout<<i+1<<endl; return 0; } if (wins1(s[0],s[1],(i%2)) == 1) { cout<<i+1<<endl; return 0; } p[0] = s[0]; p[1] = s[1]; p[2] = s[2]; } cout << "Draw" << endl; return 0; } Why must I write progam that is incomparatible to task conditions? Please fix it at once! The first I wrote program which had WA 2 Then I commented check of checker cannot move out of the board - WA 6 And finally I commented check of checker cannot move to the cell where there is another one - AC Who can explain me problem and my WA? My way was like previous. At here my opinion: It is not checkers it is stupid problem with incorrect tests. I have too delivered this problem with the third times and exactly such history... Simply fool tests :)) You are rigth man.. I was wasting my time till I read your message.. You've my night! Tnx Please, read problem statement more attentively: Loses that player, after whose move one of the opponents gets the opportunity to fell the checker. |
|