Universal Cup Judging System

Universal Cup

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓
Estadísticas

数直線上の互いに異なる位置に、$1,2,\ldots,n$ の番号が付いた $n$ 個の点電荷があります。$i$ 番目の点電荷の電荷は $q_i$、座標は $x_i$ です。この問題では、異なる 2 つの点電荷 $i$ と $j$ の間に働くクーロン力の大きさを $\frac{q_iq_j}{(x_i-x_j)^2}$ と定義します。

すべての電荷を、空でない 2 つの集合 $A$ と $B$ に分ける必要があります。一部の電荷はすでにいずれかの集合に割り当てられている場合があり、その割り当てを変更することはできません。

同じ集合に属する異なる電荷のすべての組について、力の最小値ができるだけ大きくなるように、残りの割り当てを行ってください。

入力

最初の行には、テストケースの数を表す整数 $T$ ($1\le T\le1000$) が与えられます。

各テストケースの最初の行には、点電荷の数を表す整数 $n$ ($4\le n\le10^5$) が与えられます。

続く $n$ 行のそれぞれには、2 つの整数 $q_i,x_i$ と 1 つの文字 $s_i$ ($1\le q_i\le15000$, $1\le x_i\le2\times10^5$、$s_i$ は A、B、? のいずれか) が与えられ、$i$ 番目の点電荷の電荷、座標、割り当てを表します。

  • $s_i$ が A の場合、その電荷はすでに集合 $A$ に割り当てられています。
  • $s_i$ が B の場合、その電荷はすでに集合 $B$ に割り当てられています。
  • $s_i$ が ? の場合、その電荷はまだどちらの集合にも割り当てられていません。

各テストケース内で、すべての座標は互いに異なり、少なくとも 1 つの電荷が未割り当てです。

すべてのテストケースにわたる $n$ の合計は $5\times10^5$ を超えません。

出力

各テストケースについて、同じ集合に属する異なる 2 つの電荷の間の力の最小値として達成できる最大値を、1 行に出力してください。答えは既約分数として p/q の形式で表してください。ここで $p$ と $q$ は互いに素な正の整数です。

入出力例

入力 1

2
5
3 6 ?
2 4 ?
3 1 ?
5 7 ?
4 2 ?
4
1 1 A
2 2 B
3 3 ?
4 4 B

出力 1

10/9
2/1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.