/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long

long long squaredDistance(pair<ll, ll> &a, pair<ll, ll> &b) {
    return (long long)(a.first - b.first) * (a.first - b.first) + 
           (long long)(a.second - b.second) * (a.second - b.second);
}

bool isRightAngledTriangle(pair<ll, ll> &a, pair<ll, ll> &b, pair<ll, ll> &c) {
    long long ab2 = squaredDistance(a, b);
    long long bc2 = squaredDistance(b, c);
    long long ca2 = squaredDistance(c, a);

    if (ab2 == 0 || bc2 == 0 || ca2 == 0) {
        return false; // Polls are not distinct
    }

    return (ab2 + bc2 == ca2) || (ab2 + ca2 == bc2) || (bc2 + ca2 == ab2);
}

int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> polls(N);

    for (ll i = 0; i < N; ++i) {
        cin >> polls[i].first >> polls[i].second;
    }

    set<tuple<ll, ll, ll>> uniqueTriangles;

    for (ll i = 0; i < N; ++i) {
        for (ll j = i + 1; j < N; ++j) {
            for (ll k = j + 1; k < N; ++k) {
                if (isRightAngledTriangle(polls[i], polls[j], polls[k])) {
                    vector<ll> indices = {i, j, k};
                    sort(indices.begin(), indices.end());
                    uniqueTriangles.insert(make_tuple(indices[0], indices[1], indices[2]));
                }
            }
        }
    }

    cout << uniqueTriangles.size() << endl;

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1070 Strange Sequences
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 16:55:54
Judged At
2024-11-11 03:23:22
Judged By
Score
0
Total Time
1ms
Peak Memory
532.0 KiB