結果

問題 No.2353 Guardian Dogs in Spring
ユーザー erbowlerbowl
提出日時 2023-07-07 07:22:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 2,430 ms
コンパイル使用メモリ 211,920 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-09-28 07:43:36
合計ジャッジ時間 40,781 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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(remS.size()>0){
        set<pair<ld,ll>> rem;
        
        pair<ll,ll> L = {1e18,-1};
        pair<ll,ll> mi = {1e18,-1};
        for (auto i : remS) {
            ld t = atan2(xy[i].second-now.second,xy[i].first-now.first);
            if(t>last&&t<L.first){
                L.first = t;
                L.second =i;
            }
            if(mi.first>t){
                mi.first = t;
                mi.second = i;
            }
        }
        ld theta = L.second==-1 ? mi.first : L.first;
        ll ind = L.second==-1 ? mi.second : L.second;
        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