結果

問題 No.1265 Balloon Survival
コンテスト
ユーザー Mister
提出日時 2020-10-23 22:31:52
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,030 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,171 ms
コンパイル使用メモリ 72,180 KB
最終ジャッジ日時 2026-06-14 17:38:13
合計ジャッジ時間 1,976 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:31:15: error: ‘std::tuple<long long int, int, int> <structured bindings>’ has incomplete type
   31 |     for (auto [t, i, j] : events) {
      |               ^~~~~~~~~
In file included from /usr/include/c++/12/vector:64,
                 from main.cpp:3:
/usr/include/c++/12/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/include/c++/12/bits/stl_vector.h:528:7:   required from here
/usr/include/c++/12/bits/stl_vector.h:367:49: error: invalid use of incomplete type ‘class std::tuple<long long int, int, int>’
  367 |                       _M_impl._M_end_of_storage - _M_impl._M_start);
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/bits/stl_algobase.h:64,
                 from /usr/include/c++/12/string:50,
                 from /usr/include/c++/12/bits/locale_classes.h:40,
                 from /usr/include/c++/12/bits/ios_base.h:41,
                 from /usr/include/c++/12/ios:42,
                 from /usr/include/c++/12/ostream:38,
                 from /usr/include/c++/12/iostream:39,
                 from main.cpp:1:
/usr/include/c++/12/bits/stl_pair.h:90:11: note: declaration of ‘class std::tuple<long long int, int, int>’
   90 |     class tuple;
      |           ^~~~~
In file included from /usr/include/c++/12/bits/move.h:57,
                 from /usr/include/c++/12/bits/exception_ptr.h:43,
                 from /usr/include/c++/12/exception:168,
                 from /usr/include/c++/12/ios:39:
/usr/include/c++/12/type_traits: In substitution of ‘template<class _Tp, class ... _Args> using __is_nothrow_constructible_impl = std::__bool_constant<__is_nothrow_constructible(_Tp)> [with _Tp = std::tuple<long long int, int, int>; _Args = {long long int, int&, int&}]’:
/

ソースコード

diff #
raw source code

#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