cswork / OA打开练习工作台

StripeOA #4

Proximity Request Routing (3 Parts)

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)模拟/实现位运算

  • Part 1: Datacenter registry. REGISTER <name> <lat> <lon> <capacity> — validate lat ∈ [-90, 90], lon ∈ [-180, 180], capacity ≥ 0, no duplicate names. SET_HEALTHY <name> <true/false>.
  • Part 2: Distance. DISTANCE <lat1> <lon1> <lat2> <lon2> — Haversine, return integer km.
a = sin²(Δφ / 2) + cos(φ1) · cos(φ2) · sin²(Δλ / 2)
c = 2 · atan2(sqrt(a), sqrt(1 - a))
distance = 6371 · c
  • Part 3: Routing with capacity. ROUTE <lat> <lon> — route to the nearest healthy datacenter with load < capacity. Tie → name ascending. Increment chosen datacenter's load.