結果

問題 No.1265 Balloon Survival
ユーザー snrnsidysnrnsidy
提出日時 2021-11-15 00:01:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 207,872 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2023-08-20 09:02:55
合計ジャッジ時間 4,856 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 36 ms
11,432 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 18 ms
5,160 KB
testcase_22 AC 12 ms
5,068 KB
testcase_23 AC 13 ms
5,180 KB
testcase_24 AC 64 ms
12,536 KB
testcase_25 AC 65 ms
11,856 KB
testcase_26 AC 64 ms
12,252 KB
testcase_27 AC 65 ms
11,580 KB
testcase_28 AC 64 ms
11,544 KB
testcase_29 AC 65 ms
11,868 KB
testcase_30 AC 65 ms
11,864 KB
testcase_31 AC 65 ms
12,544 KB
testcase_32 AC 66 ms
12,488 KB
testcase_33 AC 65 ms
11,460 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

bool check[1001];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    vector <pair<int,int>> v;
    int x,y;

    cin >> n;

    for(int i=0;i<n;i++)
    {
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }

    vector <pair<long long int,pair<int,int>>> vec;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            long long int dy = v[j].first - v[i].first;
            long long int dx = v[j].second - v[i].second;
            long long int D = dy*dy + dx*dx;
            vec.push_back(make_pair(D,make_pair(i,j)));
        }
    }

    sort(vec.begin(),vec.end());

    int res = 0;

    for(int i=0;i<vec.size();i++)
    {
        int u = vec[i].second.first;
        int v = vec[i].second.second;
        if(check[u] || check[v]) continue;
        if(u==0)
        {
            res++;
            check[v] = true;
        }
        else if(v==0)
        {
            res++;
            check[u] = true;
        }
        else
        {
            check[u] = true;
            check[v] = true;
        }
    }

    cout << res << '\n';

    return 0;
}
0