UVa 10535 - Shooter (最多区间覆盖的点 + 扫描)

题意

问一枪能最多能崩掉几堵墙

思路

求出墙和人的角度,一枪能崩掉这个角度里的墙,问题就转化成被覆盖最多的角度。

用左端点和右端点扫描。书上例题

因为对弧度不熟悉,所以转化为角度。。

如果相差大于180度,要分成[0, a][b, 360]。

代码

 
 
  1. #include <stack>
  2. #include <cstdio>
  3. #include <list>
  4. #include <set>
  5. #include <iostream>
  6. #include <string>
  7. #include <vector>
  8. #include <queue>
  9. #include <functional>
  10. #include <cstring>
  11. #include <algorithm>
  12. #include <cctype>
  13. #include <string>
  14. #include <map>
  15. #include <cmath>
  16. using namespace std;
  17. #define LL long long
  18. #define ULL unsigned long long
  19. #define SZ(x) (int)x.size()
  20. #define Lowbit(x) ((x) & (-x))
  21. #define MP(a, b) make_pair(a, b)
  22. #define MS(arr, num) memset(arr, num, sizeof(arr))
  23. #define PB push_back
  24. #define X first
  25. #define Y second
  26. #define ROP freopen("input.txt", "r", stdin);
  27. #define MID(a, b) (a + ((b - a) >> 1))
  28. #define LC rt << 1, l, mid
  29. #define RC rt << 1|1, mid + 1, r
  30. #define LRT rt << 1
  31. #define RRT rt << 1|1
  32. #define BitCount(x) __builtin_popcount(x)
  33. #define BitCountll(x) __builtin_popcountll(x)
  34. #define LeftPos(x) 32 - __builtin_clz(x) - 1
  35. #define LeftPosll(x) 64 - __builtin_clzll(x) - 1
  36. const double PI = acos(-1.0);
  37. const int INF = 0x3f3f3f3f;
  38. const double eps = 1e-8;
  39. const int MAXN = 1e3 + 10;
  40. const int MOD = 29;
  41. const int dir[][2] = { {1, 0}, {0, 1} };
  42. int cases = 0;
  43. typedef pair<int, int> pii;
  44. typedef pair<double, double> pdd;
  45. struct LINE
  46. {
  47. pdd l, r;
  48. }L[MAXN];
  49. vector<pair<double, int> > range;
  50. pdd pos;
  51. int n;
  52. void Convert()
  53. {
  54. range.clear();
  55. for (int i = 0; i < n; i++)
  56. {
  57. LINE tmp = L[i];
  58. double a = atan2(tmp.l.Y - pos.Y, tmp.l.X - pos.X) * 180 / PI, b = atan2(tmp.r.Y - pos.Y, tmp.r.X - pos.X) * 180 / PI;
  59. if (a < 0) a += 360;
  60. if (b < 0) b += 360;
  61. if (a > b) swap(a, b);
  62. if (b - a >= 180)
  63. {
  64. range.PB({0, 1}); range.PB({a, -1});
  65. a = b; b = 360;
  66. }
  67. range.PB({a, 1}); range.PB({b, -1});
  68. }
  69. }
  70. int cmp(pair<double, int> a, pair<double, int> b)
  71. {
  72. if (fabs(a.X - b.X) > eps) return a.X < b.X;
  73. return a.Y > b.Y;
  74. }
  75. int main()
  76. {
  77. //ROP;
  78. while (cin >> n, n)
  79. {
  80. for (int i = 0; i < n; i++) cin >> L[i].l.X >> L[i].l.Y >> L[i].r.X >> L[i].r.Y;
  81. cin >> pos.X >> pos.Y;
  82. Convert();
  83. sort(range.begin(), range.end(), cmp);
  84. int tmp = 0, ans = -1;
  85. for (int i = 0; i < SZ(range); i++)
  86. {
  87. tmp += range[i].Y;
  88. ans = max(ans, tmp);
  89. }
  90. cout << ans << endl;
  91. }
  92. return 0;
  93. }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Zombie Raid is a thrilling top-down shooter survival game set in a post-apocalyptic world overrun by zombies. The game features fast-paced action, challenging gameplay, and a variety of weapons and power-ups to help you survive. As a survivor, your goal is to protect your base from the endless waves of zombies. You'll need to use your wits and quick reflexes to stay alive and fend off the undead hordes. The game features a variety of weapons, from pistols and shotguns to assault rifles and rocket launchers, to help you take down the zombies. In addition to weapons, you can also collect power-ups like health kits, ammo crates, and special abilities to help you survive. These power-ups can be found scattered throughout the game world, so be sure to explore and scavenge as much as possible. Zombie Raid also features a variety of enemies, from slow-moving zombies to fast and agile ones, as well as bosses that require strategy and skill to defeat. You'll need to adapt to each new wave of enemies and use different tactics to survive. The game also features multiple levels, each with its own unique challenges and objectives. As you progress through the game, you'll unlock new weapons and abilities, making it easier to take on the hordes of zombies. Overall, Zombie Raid is a fun and exciting top-down shooter survival game that will keep you on the edge of your seat. With its challenging gameplay, variety of weapons and power-ups, and endless waves of zombies, it's a game that's sure to keep you entertained for hours on end.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值