結果

問題 No.1265 Balloon Survival
ユーザー MisterMister
提出日時 2020-10-23 22:31:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,030 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 71,872 KB
最終ジャッジ日時 2024-04-27 03:31:09
合計ジャッジ時間 1,027 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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 /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64,
                 from main.cpp:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/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> >]':
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:526:7:   required from here
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/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 /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:64,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/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 inclu

ソースコード

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