結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2020-10-23 22:09:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 2,169 ms |
コンパイル使用メモリ | 204,392 KB |
最終ジャッジ日時 | 2025-01-15 13:08:05 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:24:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std::literals::string_literals;using i64 = std::int_fast64_t;using std::cout;using std::cerr;using std::endl;using std::cin;template<typename T>std::vector<T> make_v(size_t a){return std::vector<T>(a);}template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}i64 calc(i64 a, i64 b, i64 c, i64 d) {return (a - c) * (a - c) + (b - d) * (b - d);}int main() {int n; scanf("%d", &n);std::vector<int> x(n), y(n);for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);std::vector<std::tuple<i64, int, int>> vec;for(int i = 0; i < n; i++) {for(int j = i + 1; j < n; j++) {vec.push_back({calc(x[i], y[i], x[j], y[j]), i, j});}}sort(begin(vec), end(vec));std::vector<int> bombed(n);std::vector<int> deleted(n);for(auto [_, i, j]: vec) {if(bombed[i] or bombed[j] or deleted[i] or deleted[j]) continue;if(i == 0) deleted[j] = true;else bombed[i] = bombed[j] = true;}printf("%d\n", std::accumulate(begin(deleted), end(deleted), 0));return 0;}