Forget who wrote the emm
Anyway, there is still no solution to the problem.
Two questions were asked during the match.
In fact, the last chance to make 05 but out of the bug
Always change and change...
Later, it was found that there were less judgment conditions.
09 Block Breaker
HDU 6699 bfs simulation
Main idea of the title: Give t group samples, each group contains matrix size n, m and q tapping positions.
Every time you tap (x,y) a small piece of that position falls.
If one block above or below the other block in the matrix is empty and one block on the left or below is empty, the block will also drop.
Find out how many block s fall after each hit (x, y) position
Train of Thought: At that time, after understanding the meaning of the question, I wanted to go through violence once.
But to determine whether the block s around you fall, you need to mark them and use bfs faster (and almost misspelled TAT)
#include <bits/stdc++.h> using namespace std; int vis[2005][2005]; int a[5] = {1, 0, -1, 0}; int b[5] = {0, 1, 0, -1}; int ans = 0, n, m; void bfs(int x, int y) { vis[x][y] = 2; for (int i = 0; i < 4; i++) { int newx = x + a[i]; int newy = y + b[i]; // printf("%d %d\n", newx, newy); if (vis[newx][newy]==0&&newx >= 1 && newx <= n && newy >= 1 && newy <= m) { if ((vis[newx + 1][newy] == 2 || vis[newx - 1][newy] == 2) && (vis[newx][newy + 1] == 2 || vis[newx][newy - 1] == 2)) { ans++; bfs(newx, newy); } } } } int main() { int t; scanf("%d", &t); while (t--) { memset(vis, 0, sizeof vis); int k, x, y; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < k; i++) { scanf("%d%d", &x, &y); if (vis[x][y] == 2) { ans = 0; } else { ans = 1; bfs(x, y); } printf("%d\n", ans); } } return 0; }
03 Valentine's Day
HDU 6693 Greedy thinking
Main idea of the title: Give t group samples, each group sample has n happy value of gifts, ask how to make the k gifts sent to the other party happy once the highest value?
Idea: First, rank the happy values, then choose one, two, three... n gifts, calculate the happy value, take the maximum value.
#include <bits/stdc++.h> using namespace std; double a[100005], b[100005]; double run(int x) { double y , m = 0; if (x == 1) { return a[1]; } for (int i = 1; i <= x; i++) { y = a[i]; for (int j = 1; j <= x; j++) if (i != j) { y = y * (1 - a[j]); } m += y; } // printf("%lf **\n",m); return m; } bool cmp(double a, double b) { return a > b; } int main() { int t, n; scanf("%d", &t); while (t--) { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%lf", &a[i]); } sort(a + 1, a + n + 1, cmp); double ans = 0; for (int i = 1; i <= n; i++) { double mm = run(i); if (ans < mm) { ans = mm; } else { break; } } // printf("%lf\n", run(2)); printf("%.12lf\n", ans); } return 0; }