結果

問題 No.1265 Balloon Survival
ユーザー tnakao0123
提出日時 2020-10-24 19:38:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,514 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 96,748 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-07-21 15:30:09
合計ジャッジ時間 2,945 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

/* -*- coding: utf-8 -*-
*
* 1265.cc: No.1265 Balloon Survival - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 1000;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;
/* typedef */
typedef long long ll;
struct Trpl {
ll d;
int i, j;
Trpl() {}
Trpl(ll _d, int _i, int _j): d(_d), i(_i), j(_j) {}
bool operator<(const Trpl &t) const { return d < t.d; }
void print() { printf("%lld:%d,%d\n", d, i, j); }
};
/* global variables */
int xs[MAX_N], ys[MAX_N];
Trpl ts[MAX_M];
bool used[MAX_N];
/* subroutines */
inline ll dist2(int i, int j) {
int dx = xs[j] - xs[i], dy = ys[j] - ys[i];
return (ll)dx * dx + (ll)dy * dy;
}
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);
int m = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
ts[m++] = Trpl(dist2(i, j), i, j);
sort(ts, ts + m);
int c = 0;
for (int k = 0; k < m; k++) {
//ts[k].print();
int i = ts[k].i, j = ts[k].j;
if (i == 0) {
if (! used[j]) used[j] = true, c++;
}
else {
if (! used[i] && ! used[j])
used[i] = used[j] = true;
}
}
printf("%d\n", c);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0