結果

問題 No.2353 Guardian Dogs in Spring
ユーザー erbowlerbowl
提出日時 2023-07-07 06:36:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,150 bytes
コンパイル時間 2,192 ms
コンパイル使用メモリ 216,792 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-28 07:00:09
合計ジャッジ時間 11,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n;
    std::cin >> n;
    vector<pair<ll,ll>> xy(n);
    vector<ll> ans;
    set<ll> remS;
    for (int i = 0; i < n; i++) {
        std::cin >> xy[i].first >> xy[i].second;
        if(xy[i].first==0&&xy[i].second==0){
            ans.push_back(i);
        }else{
            remS.insert(i);
        }
    }
    pair<ll,ll> now = {0,0};
    ld last = 0;
    while(true){
        vector<pair<ld,ll>> rem;
        for (auto i : remS) {
            rem.push_back({atan2(xy[i].second-now.second,xy[i].first-now.first), i});
        }
        if(rem.size()==0)break;
        sort(rem.begin(),rem.end());
        auto it = lower_bound(rem.begin(),rem.end(),make_pair(last,-1ll));
        if(it==rem.end())it=rem.begin();
        auto [theta, ind] = *it;
        last = theta;
        remS.erase(ind);
        now = xy[ind];
        ans.push_back(ind);
    }
    std::cout << ans.size()/2 << std::endl;
    for (int i = 0; i < ans.size()/2; i++) {
        std::cout << ans[2*i]+1<<" "<<ans[2*i+1]+1 << std::endl;
    }
}
0