#include <iostream>
#include <cmath>
#include <tuple>
#include <cstdint>
#include <vector>
#include <random>
#include <algorithm>
typedef std::tuple<std::int64_t, std::int64_t, std::int64_t,std::uint64_t> Data;//x.y,r;
typedef std::vector<Data> DType;
DType MakeVector(std::size_t N,unsigned int S,std::int64_t Min=0,std::int64_t Max=32) {
std::minstd_rand mr(S);
std::uniform_int_distribution<std::int64_t> UI(Min, Max);
std::uniform_int_distribution<std::int64_t> UIR(1, 13);
DType D;
for (std::size_t i = 0; i < N; i++) {
D.push_back({ UI(mr), UI(mr), UIR(mr), 0 });
}
return D;
}
bool Conflict(const Data& A, const Data& B) {
std::int64_t X = std::abs(std::get<0>(B) - std::get<0>(A));
std::int64_t Y = std::abs(std::get<1>(B) - std::get<1>(A));
std::int64_t R = std::abs(std::get<2>(B) +std::get<2>(A));
return std::hypot(X, Y) <= R;
}
std::uint64_t MakeHoge(DType& D) {
std::uint64_t C = 0;
std::uint64_t R = 0;
for (std::size_t i = 0; i < D.size(); i++) {
for (std::size_t j = 0; j < D.size(); j++) {
if (i == j)continue;
std::int64_t X = std::abs(std::get<0>(D[j]) - std::get<0>(D[i]));
std::int64_t Y = std::abs(std::get<1>(D[j]) - std::get<1>(D[i]));
std::int64_t R = std::abs(std::get<2>(D[j]) + std::get<2>(D[i]));
//if (X*X+Y*Y <= R*R) { C++; }
if (std::hypot(X, Y) <= R) { C++; }
}
R = std::max(R, C);
std::get<3>(D[i]) = C;
C = 0;
}
return R;
}
bool Show(const DType& D, const std::uint64_t N) {
std::cout << "MaxCross:" << N <<"count" <<std::endl;
for (auto& o : D) {
std::cout << "X:" << std::get<0>(o) << " Y=" << std::get<1>(o) << " R=" << std::get<2>(o) << " Hit:" << std::get<3>(o)<< std::endl;
}
return true;
}
int main() {
std::uint64_t R = 0;
DType D;
D = MakeVector(12, 1, 0, 32);
R = MakeHoge(D);
Show(D, R);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmN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