結果

問題 No.1265 Balloon Survival
ユーザー MisterMister
提出日時 2020-10-23 22:31:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,030 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 71,144 KB
最終ジャッジ日時 2023-09-28 16:38:35
合計ジャッジ時間 1,119 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: 関数 ‘void solve()’ 内:
main.cpp:31:15: エラー: ‘std::tuple<long long int, int, int> <structured bindings>’ has incomplete type
   31 |     for (auto [t, i, j] : events) {
      |               ^~~~~~~~~
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/vector:64,
         次から読み込み:  main.cpp:3:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::tuple<long long int, int, int>; _Alloc = std::allocator<std::tuple<long long int, int, int> >]’:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h:526:7:   required from here
/usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h:367:49: エラー: invalid use of incomplete type ‘class std::tuple<long long int, int, int>’
  367 |                       _M_impl._M_end_of_storage - _M_impl._M_start);
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/stl_algobase.h:64,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/string:50,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/locale_classes.h:40,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/ios_base.h:41,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ios:42,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ostream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/iostream:39,
         次から読み込み:  main.cpp:1:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_pair.h:90:11: 備考: declaration of ‘class std::tuple<long long int, int, int>’
   90 |     class tuple;
      |           ^~~~~
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/move.h:57,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/exception_ptr.h:43,
         次か

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::pair<lint, lint>> ps(n);
    for (auto& [x, y] : ps) std::cin >> x >> y;

    std::vector<std::tuple<lint, int, int>> events;
    for (int i = 0; i < n; ++i) {
        auto [xi, yi] = ps[i];
        for (int j = 0; j < i; ++j) {
            auto [xj, yj] = ps[j];

            auto dx = xi - xj,
                 dy = yi - yj;

            events.emplace_back(dx * dx + dy * dy, j, i);
        }
    }

    std::sort(events.begin(), events.end());

    std::vector<bool> erased(n, false);
    int ans = 0;
    for (auto [t, i, j] : events) {
        if (erased[i] || erased[j]) continue;

        if (i == 0) {
            ++ans;
            erased[j] = true;
        } else {
            erased[i] = erased[j] = true;
        }
    }

    std::cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0