TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

小 K 現在有太多的複數了,所以希望你能夠幫助他把部份的複數儲存起來並依照絕對值由小而大排序(若絕對值相同時則以實部排序)。

一個虛數 $a + bi$ 的絕對值為 $\sqrt {a^ 2 + b^ 2}$

請在程式碼最前面引入標頭檔 lib0622.h,並實作以下功能:

  • 主程式
    會需要用到以下三種函式:

    • Init(int& Q);
      • $Q$ 代表詢問的次數
    • Get_Query(int& N, complex_number*& cpx);
      • $N$ 代表複數的個數
      • $cpx$ 代表複數的指標
    • Answer(int N, complex_number* cpx)
      • $N$ 代表複數的個數
      • $cpx$ 代表複數的指標
    • 一開始要透過 Init 得知要作 $Q$ 次詢問。接著在每次詢問中,需要先透過 Get_Query 得知要排序的複數個數及內容,並藉由 Answer 回覆。

Hint: 可以多載運算子 < 來協助排序。

注意此題不需要任何的輸入或輸出,否則將會發生不可預期的結果。

若你的結構實作不符合需求,除了獲得 Wrong Answer 之外,你更有可能獲得 Compile ErrorRuntime Error

提示:你可能會需要 include 需要的標頭檔來迴避 Compile Error

如果還是不確定該如何進行,可以參考以下的程式碼進行修改:

#include "lib0622.h"

int main(){
    int Q;
    Init (Q);
    while(Q--){
        int N;
        complex_number* cpx;
        Get_Query(N, cpx);
        // TODO (do some sorting)
        Answer(N, cpx);
    }
}

Input Format

本題沒有輸入,隨意輸入將會得到不可預期的結果。

Output Format

本題沒有輸出,隨意輸出將會得到不可預期的結果。

Sample Input 1

2
1
-869.655 304.215
1
-150.875 878.239

Sample Output 1

1
-869.655 304.215
1
-150.875 878.239

Sample Input 2

2
3
-15.3115 800.511
334.103 -466.527
132.681 241.486
3
-575.281 -93.2971
-552.458 -992.734
612.328 -603.508

Sample Output 2

3
132.681 241.486
334.103 -466.527
-15.3115 800.511
3
-575.281 -93.2971
612.328 -603.508
-552.458 -992.734

Hints

測試用標頭檔
這裡提供一份本地測試用的標頭檔,你可以將其複製下來存檔成 lib0622.h#include "lib0622.h" 做使用。但請注意,這只是測試用的標頭檔,一些與解題無關的行為將會與 judge 上的有所不同,因此請不要嘗試任何與解題無關的行為,很可能會導致各種不可預期的後果。

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~1 範例測資 0
2 0~11 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 2
1 1000 524288 65536 1 2
2 1000 524288 65536 2
3 1000 524288 65536 2
4 1000 524288 65536 2
5 1000 524288 65536 2
6 1000 524288 65536 2
7 1000 524288 65536 2
8 1000 524288 65536 2
9 1000 524288 65536 2
10 1000 524288 65536 2
11 1000 524288 65536 2