38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#include <cmath>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct Vector2D {
|
|
int64_t x, y;
|
|
};
|
|
|
|
int main() {
|
|
std::fstream input("input");
|
|
std::string currentLine = "";
|
|
std::vector<Vector2D> points{};
|
|
int64_t password = 0;
|
|
|
|
while (std::getline(input, currentLine, '\n')) {
|
|
uint16_t positionOfTheComma = currentLine.find(',');
|
|
points.push_back({std::stoll(currentLine.substr(0, positionOfTheComma)),
|
|
std::stoll(currentLine.substr(positionOfTheComma + 1))});
|
|
}
|
|
|
|
uint64_t count = 0, pointsSize = points.size();
|
|
for (Vector2D &point : points) {
|
|
for (uint64_t index = ++count; index < pointsSize; index++) {
|
|
Vector2D *position1 = &point, *position2 = &points[index];
|
|
int64_t area = (std::abs(position2->x - position1->x) + 1) *
|
|
(std::abs(position2->y - position1->y) + 1);
|
|
if (area > password) {
|
|
password = area;
|
|
}
|
|
}
|
|
}
|
|
std::cout << password << std::endl;
|
|
}
|