Show all threads Hide all threads Show all messages Hide all messages | easy bfs | 👑TIMOFEY👑 | 1338. Automobiles | 17 Jul 2024 16:53 | 2 | Yeah, but i hate bfs on grid | Please give me output for my input. | {AESC USU} Dembel | 1338. Automobiles | 14 Nov 2014 17:08 | 2 | I have Wa#4. Please help me! #input 5 5 ooooo ooooo ooooo ooooo ooooo 2 1 13 #output ??? 5 5 ooooo ooooo ooooo ooooo ooooo 2 1 13 ans: Experiment #1: North: 4, South: 0, East: 20, West: 0 Experiment #2: North: 2, South: 2, East: 10, West: 10 | WA#41 | NotImplemented | 1338. Automobiles | 3 Jun 2013 19:48 | 1 | WA#41 NotImplemented 3 Jun 2013 19:48 Can you give me a hint with test #41? | How to avoid TLE#42 ? | KALO | 1338. Automobiles | 18 Nov 2010 02:00 | 1 | | Need help - WA2 | Lebedev_Nicolay[Ivanovo SPU] | 1338. Automobiles | 15 Jun 2009 01:25 | 1 | I pass all tests, that I think up. Can anybody give me more tests??? | sample input? | Alias (Alexander Prudaev) | 1338. Automobiles | 8 Aug 2007 00:57 | 2 | i think these one car can't came from south, because point #4 is most southern. There is no point to the south of a point number 4. please explain me sample input, i don't understand The point 4 is 2nd row 6 column. One car comes from Sount point 3 (2nd row 3 column). Cars from point 1 and 2 can't get 4point. | WA #17 (My code is here) | wwwwww | 1338. Automobiles | 8 Feb 2006 21:36 | 6 | Please, give me some tests or hints. Problem is easy... Only BFS, nothing more. But WA #17 (even after hours of debuging and testing) My code: #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 503 #define MAX2 (MAX * MAX) char S[MAX][MAX]; int N = 0, H, W, M, D[MAX][MAX], To[MAX][MAX]; int X[MAX2], Y[MAX2], Qx[MAX2], Qy[MAX2]; int Po, Si, Num[MAX]; int Co( int x, int y ) { return 0 <= x && x < W && 0 <= y && y < H && (S[y][x] == '#' || S[y][x] == 'o'); } int main( void ) { int i, j, k, m, x, y, d, to, x1, y1; int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; scanf("%d%d", &W, &H); for (i = 0; i < H; i++) scanf("%s", S[i]); for (i = H - 1; i >= 0; i--) for (j = 0; j < W; j++) if (S[i][j] == 'o') X[++N] = j, Y[N] = i; scanf("%d", &M); for (m = 1; m <= M; m++) { scanf("%d", &k); memset(D, -1, sizeof(D)); Po = 0, Si = 0, D[Y[k]][X[k]] = 0; for (i = 0; i < 4; i++) if (Co(x = X[k] + dx[i], y = Y[k] + dy[i])) D[y][x] = 1, To[y][x] = i, Qx[Si] = x, Qy[Si++] = y; while (Po < Si) { x = Qx[Po], y = Qy[Po++], d = D[y][x] + 1, to = To[y][x]; for (i = 0; i < 4; i++) if (Co(x1 = x + dx[i], y1 = y + dy[i])) if (D[y1][x1] == -1 || (D[y1][x1] == d && To[y1][x1] > to)) { if (D[y1][x1] == -1) Qx[Si] = x1, Qy[Si++] = y1; D[y1][x1] = d, To[y1][x1] = to; } } memset(Num, 0, sizeof(Num)); for (i = 1; i <= N; i++) if (i != k && D[Y[i]][X[i]] != -1) Num[To[Y[i]][X[i]]]++; printf("Experiment #%d: North: %d, South: %d, East: %d, West: %d\n", m, Num[1], Num[0], Num[3], Num[2]); } return 0; } Edited by author 25.01.2006 13:14 No overflow, so there is a mistake in BFS... But where is it??? I also have WA#17 and can't find mistake in my program. May be we don't understand the problem. There is no mistke in BFS, but in using BFS. "Priorities acts" means that if car can turn for South and for North it turns for South. I had WA #17 too, because I thought that car chooses the side from that it comes to checkpoint. Try this test: 7 7 ###.... #.#.... #.#.### #.#.o.# #.###.# o.....# ####### 1 1 The answer is: Experiment #1: North: 1, South: 0, East: 0, West: 0 Thank you! I'll fix my bag. (wwwwww - my old login) | WA on test 42 | Alexandru Popa | 1338. Automobiles | 31 Aug 2005 02:06 | 2 | Would anybody tell me how looks test 42 (or what's the trick) ? I have tle on test 42. May be, it's something like oooooo...oooooo (500 times) ............... oooooo...oooooo (500 times) ??? | HELP! | epuise | 1338. Automobiles | 15 Jul 2005 16:39 | 2 | HELP! epuise 15 Jul 2005 16:34 Why the sample output is: Experiment #1: North: 0, South: 1, East: 0, West: 0 And what does it mean? "Assume that the checkpoints are numbered bottom-up and from left to right." I think the sample output should be: Experiment #1: North: 3, South: 0, East: 0, West: 0 | What is it about test #13? | Furtuna Dan Emanuel | 1338. Automobiles | 13 Apr 2005 18:31 | 2 | Did somebody have any trouble whith this test? I just can't pas it. Thanks in advance. I found out what was wrong: I didn't pay attention to the neighbours. But now it WA test #17. | AC (+) | Dmitry 'Diman_YES' Kovalioff | 1338. Automobiles | 22 Feb 2005 14:26 | 1 | AC (+) Dmitry 'Diman_YES' Kovalioff 22 Feb 2005 14:26 The algo is O(W*H*M) - the only BFS for each experiment in fact. By the way, Memory Limit it too huge. My program on Pascal uses 3399 Kb only. | why wrong answer #1 ? | thwomass | 1338. Automobiles | 21 Feb 2005 15:18 | 1 | is there something special about this problem's output ? |
|
|