Общий форумinput: 2 1 600000 1 600001 output: 599999 The problem is not that difficult, therefore for me the most interesting question is the smallest program possible to write for this problem. Let's define the size of the program as H x W in your solution. Mine is 6 x 8. Who's smaller? =) I've constructed 5 x 6 shortly after reading the prob, trying to do better in the next several hours but failed. For big tests (at least for n >= 44, but may be works for smaller n's) you can assume that firstt 4 numbers are 33 11 22 44 Edited by author 07.10.2024 02:40 Why I have WA#10? I can't think test to get wrong answer. PLS help me Next my code: #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { double a, b, c, x, y, x2, y2; double X, Y, Z, X2, Y2, Z2; double result = 0; bool bflag = true; cin >> a >> b >> c; for (int i=0; i < 2; i++) { cin >> x >> y; if (x < c) { X = 0; Y = y - b - c; Z = x; } else if (x > c + a) { X = a; Y = y - b - c; Z = 2 * c + a - x; } else { if (y <= b) { X = x - c; Y = b - y; Z = 0; } else if (y <= b + c) { X = x - c; Y = 0; Z = y - b; } else if (y <= b) { X = x - c; Y = y - b - c; Z = c; } else { X = x - c; Y = b; Z = 2 * b + 2 * c - y; } } if (bflag) { x2 = x; y2 = y; X2 = X; Y2 = Y; Z2 = Z; bflag = false; } } //cout << X << ' ' << Y << ' ' << Z << ' ' << X2 << ' ' << Y2 << ' ' << Z2; это типа отладка X2 -= X; Y2 -= Y; Z2 -= Z; result = sqrt(X2 * X2 + Y2 * Y2 + Z2 * Z2); if (result < 1.E-8) cout << fixed << setprecision(6) << 0; else cout << fixed << setprecision(6) << result; return 0; } Sorry, I'm find mistake now, it's a one wrong if in my code, thk all to find this подскажите в какие там данные входные If I delete a branch, does it means that I delete also its sub-braches? +1 please clarify Yes, you cannot have two or more components #include <cstdio> int ncall; int call[100]; void solve(int K) { if (!K) return; if (K % 2 == 0) { call[ncall] = ++ncall; if (K > 2) solve(K / 2); } else { call[ncall++] = -1; solve(K - 1); } } int main( void ) { // freopen( "p1278.in", "r", stdin ); int K; scanf( "%d", &K ); if (K > 1) solve(K); for (int i = 0; i < ncall; i++) printf( "CALL %d\n", call[i] < 0 ? ncall : call[i] ); printf( "BELL&RET\n" ); return 0; } For test #1, K = 4, and my code output: CALL 1 CALL 2 BELL&RET I think it's correct. When finding intersection of segments (a, b) and (c, d) I am finding t1, t2, such that a + (b - a) * t1 = c + (d - a) * t2, -eps <= t1 <= 1+eps, -eps <= t2 <= 1+eps. This code doesn't work for eps=1e-12, but works for eps=0. THIS IS MINDBLOWING Do you know the test#3? i use heap in this problem but got WA#3. please help. sorry for poor english. thank. i used also heap. Who knows test #3 ???. Help me please!!! try numbers in descending order If you are using heap then use should also use something that will store the count of elements because we also have to remove the previous elements that are not in window of size m Use stacks. Push one letter by letter. If stack.top() == current letter, pop the stack. else push the letter in the stack. You could also use deque. wrong epsilon, precision problems def get_max(arr): res = arr[0] maxEnding = arr[0] for i in range(1, len(arr)): maxEnding = max(maxEnding + arr[i], arr[i]) res = max(res, maxEnding)
return res Some hints for solving this problem the way I was able to solve it, without greedy search 1. I used BFS search with heuristic (A* search). As a heuristic, I used the sum of the distances from the boxes to the nearest goals, taking into account that different boxes should be on different goals. It is better to distribute boxes among goals in some greedy way, so as not to spend a lot of time on this. 2. In the board states, DO NOT store the position of the player, store the places he can REACH. This will greatly reduce the number of states needed to be stored. You can store one board state in two 64-bit numbers as bit masks. 3. To find bad positions and stop further search on them, look for simple deadlocks (the box is in a corner and not on a target), dynamic deadlocks (the boxes block each other) and NOT COMPLEX corral deadlocks (the boxes are not on goals and block access to some board area, so they cannot be pushed out of there). 4. If you try to search for too complex corral deadlocks, the time spent on finding them will not be worth it. Try different settings of what difficulty of corral deadlocks to search for and when to stop the search. Store the found configurations of corral deadlocks (and the configurations in which no deadlock was found) in some sets so as not to determine them every time. 5. In addition to the forward search (pushing boxes from the starting positions to the goals), you can also use the backward search (pulling boxes from the goals to the starting positions) to reduce the depth of the search tree. 6. For the forward (backward) search, prevent situations when, for example, there are more (fewer) boxes near the wall than goals. This can greatly speed up the search for some boards. 7. To understand why your algorithm is working too long for a particular board, you can find and output long deadlock branches - a sequence of pushes/pulls in the search tree that starts from one of the board states that is in the found solution and that does not eventually lead to the solution. This way you can find bugs when the algorithm did not find one of the types of deadlocks and did not stop searching on them. Good luck! если второй пересыпает первому, то у первого должно быть больше, а не наоборот! А если это a1 и b1, соответственно, то это и есть ответ! Потому что a1 и b1 это изначальные мерки, до пересыпаний, в задаче так описано Edited by author 22.09.2024 01:35 Edited by author 22.09.2024 01:36 Edited by author 22.09.2024 01:36 Edited by author 22.09.2024 01:37 What could be the reason??? I think it sholud be said in statement that we do rounding to near number. I spent 20 minutes, understanding why my code doesn't work for sample test, but the mistake was here: floor(100*x)/100, because I thought we should round to bottom Who can help me? thanks. Give me some tests. i found you got AC finally. can you tell me what is the trick, thx. faint , the input is the number of the people who finished the contest. Yes, second line contains number of participant. So test example (3 5 1 4 2 6) means that participant #3 finished first, participant #5 finished second and so on. again I couldn't solve this problem because of bad understanding of problem..... I have had the same experience D: LaVuna Edited by author 12.09.2024 02:03 Edited by author 12.09.2024 02:03 Здравствуйте! Не воспринимает компилятор директивы #include <iostream> #include <map> #include <vector> #include <algorithm> #include <tuple> #include <string> Ошибка: fatal error: map: No such file or directory 2 | #include <map> | ^~~~~ compilation terminated. ----------------------------------------------- В чём проблема? Hello. It's better to use English at forum) Idk why your code don't work, but with "G++ 13.2 x64" u can use: #include <bits/stdc++.h> It is basically a header file that includes every standard library. If u use it you don't need to include anything else from STL. How to prove that such constraints on bruteforce are working finely? Edited by author 08.09.2024 07:01 |
|