結果
| 問題 |
No.1265 Balloon Survival
|
| コンテスト | |
| ユーザー |
KoD
|
| 提出日時 | 2020-10-23 22:29:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 3,106 bytes |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 68,604 KB |
| 最終ジャッジ日時 | 2025-01-15 13:27:20 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:18:18: error: ‘int32_t’ in namespace ‘std’ does not name a type
18 | template <class T, class U>
| ^~~~~~~
main.cpp:19:18: error: ‘int64_t’ in namespace ‘std’ does not name a type
19 | constexpr bool chmin(T &lhs, const U &rhs) {
| ^~~~~~~
main.cpp:20:18: error: ‘uint32_t’ in namespace ‘std’ does not name a type; did you mean ‘wint_t’?
20 | if (lhs > rhs) { lhs = rhs; return true; }
| ^~~~~~~~
| wint_t
main.cpp:21:18: error: ‘uint64_t’ in namespace ‘std’ does not name a type; did you mean ‘wint_t’?
21 | return false;
| ^
| wint_t
main.cpp:25:11: error: ‘i32’ does not name a type
25 | constexpr bool chmax(T &lhs, const U &rhs) {
| ^~~
main.cpp:26:11: error: ‘i64’ does not name a type
26 | if (lhs < rhs) { lhs = rhs; return true; }
| ^~~
main.cpp: In function ‘int main()’:
main.cpp:31:15: error: ‘i64’ was not declared in this scope
31 | * @title Chmin/Chmax
| ^~~
main.cpp:31:18: error: template argument 1 is invalid
31 | * @title Chmin/Chmax
| ^
main.cpp:31:18: error: template argument 2 is invalid
main.cpp:33:18: error: invalid types ‘int[long int]’ for array subscript
33 | #line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"
| ^
main.cpp:33:26: error: invalid types ‘int[long int]’ for array subscript
33 | #line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"
| ^
main.cpp:36:23: error: ‘state’ was not declared in this scope; did you mean ‘static’?
36 |
| ^
| static
main.cpp:36:47: error: template argument 2 is invalid
36 |
|
ソースコード
#line 1 "main.cpp"
/**
* @title Template
*/
#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>
#include <queue>
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/chmin_chmax.cpp"
template <class T, class U>
constexpr bool chmin(T &lhs, const U &rhs) {
if (lhs > rhs) { lhs = rhs; return true; }
return false;
}
template <class T, class U>
constexpr bool chmax(T &lhs, const U &rhs) {
if (lhs < rhs) { lhs = rhs; return true; }
return false;
}
/**
* @title Chmin/Chmax
*/
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"
#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"
class range {
public:
class iterator {
private:
int64_t M_position;
public:
constexpr iterator(int64_t position) noexcept: M_position(position) { }
constexpr void operator ++ () noexcept { ++M_position; }
constexpr bool operator != (iterator other) const noexcept { return M_position != other.M_position; }
constexpr int64_t operator * () const noexcept { return M_position; }
};
class reverse_iterator {
private:
int64_t M_position;
public:
constexpr reverse_iterator(int64_t position) noexcept: M_position(position) { }
constexpr void operator ++ () noexcept { --M_position; }
constexpr bool operator != (reverse_iterator other) const noexcept { return M_position != other.M_position; }
constexpr int64_t operator * () const noexcept { return M_position; }
};
private:
const iterator M_first, M_last;
public:
constexpr range(int64_t first, int64_t last) noexcept: M_first(first), M_last(std::max(first, last)) { }
constexpr iterator begin() const noexcept { return M_first; }
constexpr iterator end() const noexcept { return M_last; }
constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(*M_last - 1); }
constexpr reverse_iterator rend() const noexcept { return reverse_iterator(*M_first - 1); }
};
/**
* @title Range
*/
#line 17 "main.cpp"
using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;
constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;
int main() {
usize N;
std::cin >> N;
std::vector<i64> A(N), B(N);
for (auto i: range(0, N)) {
std::cin >> A[i] >> B[i];
}
using state = std::tuple<i64, usize, usize>;
std::priority_queue<state, std::vector<state>, std::greater<state>> que;
for (auto i: range(0, N)) {
for (auto j: range(i + 1, N)) {
que.emplace((A[i] - A[j]) * (A[i] - A[j]) + (B[i] - B[j]) * (B[i] - B[j]), i, j);
}
}
std::vector<bool> done(N);
usize ans = 0;
while (!que.empty()) {
const auto [d, u, v] = que.top();
que.pop();
if (done[u] || done[v]) {
continue;
}
if (u == 0) {
done[v] = true;
ans += 1;
}
else {
done[u] = true;
done[v] = true;
}
}
std::cout << ans << '\n';
return 0;
}
KoD