Submission #9361069


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, d;
    cin >> n >> d;
    vector<vector<double>> x(n, vector<double>(d));

    for (auto& row : x) {
        for (auto& e : row) {
            cin >> e;
        }
    }

    auto isInteger = [](double x) -> bool {
        return std::floor(x) == x;
    };

    int cnt = 0;
    for (size_t j = 0; j < n; ++j)
    {
        for (size_t i = 0; i < j; ++i)
        {
            double acc = 0.0;
            for (size_t k = 0; k < d; ++k)
            {
                acc += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            double distance = std::sqrt(acc);
            if (isInteger(distance)
                && (fabs(acc) > std::numeric_limits<double>::epsilon())
                )
            {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Submission Info

Submission Time
Task B - Good Distance
User mmatthew_43
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1652 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
All 200 / 200 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
testcase_01 1 ms 256 KB
testcase_02 1 ms 256 KB
testcase_03 1 ms 256 KB
testcase_04 1 ms 256 KB
testcase_05 1 ms 256 KB
testcase_06 1 ms 256 KB
testcase_07 1 ms 256 KB
testcase_08 1 ms 256 KB
testcase_09 1 ms 256 KB
testcase_10 1 ms 256 KB