Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define all(x) (x).begin(),(x).end()
- using namespace std;
- using ll = long long;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int n;
- cin >> n;
- vector<int> x(n), y(n);
- for (int i = 0; i < n; i++) {
- cin >> x[i] >> y[i];
- }
- vector<pair<ll, pair<int,int>>> lines;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < i; j++) {
- lines.push_back({(x[i] - x[j]) * 1ll * (x[i] - x[j]) + (y[i] - y[j]) * 1ll * (y[i] - y[j]), {i, j}});
- }
- }
- sort(all(lines), greater<>());
- auto cw = [&] (int x1, int y1, int x2, int y2) {
- return 1ll * x1 * y2 == 1ll * x2 * y1;
- };
- double answer = 0;
- vector<vector<int>> used(n);
- for (auto& [len, p] : lines) {
- auto& [i, j] = p;
- bool good = true;
- for (int v : used[i]) {
- if (cw(x[i] - x[j], y[i] - y[j], x[i] - x[v], y[i] - y[v])) {
- good = false;
- }
- }
- for (int v : used[j]) {
- if (cw(x[i] - x[j], y[i] - y[j], x[j] - x[v], y[j] - y[v])) {
- good = false;
- }
- }
- if (good) {
- answer += sqrt(len);
- }
- used[i].push_back(j);
- used[j].push_back(i);
- }
- cout << fixed << setprecision(0) << answer << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement