# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152610 | jmuzhen | Geometrija (COCI21_geometrija) | C++20 | 1 ms | 324 KiB |
#include<bits/stdc++.h>
using namespace std;
struct Point
{
int x, y;
};
struct Line {
double m, c; // to define the line: y = mx+c
double s, e; // to define the start and end x-value of segment
};
constexpr double INF = 1e12;
Line to_line(Point a, Point b) {
if (a.x > b.x) swap(a,b); // ensure a.x <= b.x
Line l;
if (a.x == b.x) {
l.m = INF;
// special line. the c value is the x value and
// s,e are the y values instead of x.
l.c = a.x;
l.s = a.y; l.e = b.y;
}
else {
l.m = (double)(a.y - b.y) / (double)(a.x - b.x);
// y = mx+c so c = y - mx
l.c = a.y - l.m * a.x;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |