結果

問題 No.5007 Steiner Space Travel
ユーザー trineutrontrineutron
提出日時 2022-07-31 03:45:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 1,224 bytes
コンパイル時間 2,003 ms
実行使用メモリ 6,952 KB
スコア 4,202,537
最終ジャッジ日時 2022-07-31 03:45:23
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,948 KB
testcase_01 AC 2 ms
4,904 KB
testcase_02 AC 2 ms
4,900 KB
testcase_03 AC 2 ms
4,904 KB
testcase_04 AC 1 ms
4,904 KB
testcase_05 AC 2 ms
4,900 KB
testcase_06 AC 1 ms
6,948 KB
testcase_07 AC 1 ms
4,904 KB
testcase_08 AC 1 ms
4,904 KB
testcase_09 AC 2 ms
4,904 KB
testcase_10 AC 2 ms
4,900 KB
testcase_11 AC 4 ms
4,900 KB
testcase_12 AC 1 ms
6,948 KB
testcase_13 AC 2 ms
4,900 KB
testcase_14 AC 2 ms
4,900 KB
testcase_15 AC 2 ms
6,948 KB
testcase_16 AC 1 ms
6,948 KB
testcase_17 AC 2 ms
4,900 KB
testcase_18 AC 2 ms
6,952 KB
testcase_19 AC 2 ms
4,904 KB
testcase_20 AC 2 ms
4,900 KB
testcase_21 AC 1 ms
6,948 KB
testcase_22 AC 2 ms
4,900 KB
testcase_23 AC 1 ms
6,952 KB
testcase_24 AC 2 ms
4,904 KB
testcase_25 AC 2 ms
4,904 KB
testcase_26 AC 1 ms
4,904 KB
testcase_27 AC 2 ms
6,952 KB
testcase_28 AC 2 ms
4,904 KB
testcase_29 AC 2 ms
4,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; i++) {
        cout << "500 500" << endl;
    }

    auto comp = [&](int x, int y) {
        return atan2(b[x] - 500, a[x] - 500) < atan2(b[y] - 500, a[y] - 500);
    };

    vector<int> ord(n + 1);
    for (int i = 0; i < n; i++) {
        ord[i] = i;
    }
    ord[n] = 0;
    sort(ord.begin() + 1, ord.end() - 1, comp);

    vector<int> t, r;
    for (int i = 0; i < n; i++) {
        t.push_back(1);
        r.push_back(ord[i] + 1);
        int a0 = a[ord[i]], a1 = a[ord[i + 1]];
        int b0 = b[ord[i]], b1 = b[ord[i + 1]];
        int dx = a1 - a0, dx0 = a0 - 500, dx1 = a1 - 500;
        int dy = b1 - b0, dy0 = b0 - 500, dy1 = b1 - 500;
        if (5 * (dx * dx + dy * dy) >
            dx0 * dx0 + dy0 * dy0 + dx1 * dx1 + dy1 * dy1) {
            t.push_back(2);
            r.push_back(1);
        }
    }
    t.push_back(1);
    r.push_back(1);

    int v = t.size();
    cout << v << endl;
    for (int i = 0; i < v; i++) {
        cout << t[i] << ' ' << r[i] << endl;
    }
    return 0;
}
0