# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105414 | alexpetrescu | Highway design (CEOI12_highway) | C++14 | 4 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
#include "office.h"
inline void solve(int n, int a, int b, int c, int d) {
int e = 0, f = 0, poz = 6;
while (poz + 1 <= n && e == 0) {
if (!isOnLine(1, poz, poz + 1)) {
if (c == 0)
c = poz, d = poz + 1;
else
e = poz, f = poz + 1;
}
poz += 2;
}
if (e == 0)
Answer(1, a, c, d);
else {
if (isOnLine(1, a, c))
c = d;
if (isOnLine(1, a, e))
e = f;
Answer(1, a, c, e);
}
}
int main() {
int n = GetN();
int A = isOnLine(1, 2, 3), B = isOnLine(1, 4, 5);
if (A || B) {
int doi = 2, trei = 3, patru = 4, cinci = 5;
if (!A) {
std::swap(doi, patru);
std::swap(trei, cinci);
}
if (B)
solve(n, doi, trei, 0, 0);
else
solve(n, doi, trei, patru, cinci);
return 0;
}
if (isOnLine(2, 3, 4)) {
int poz = 6;
while (poz + 1 <= n && isOnLine(2, poz, poz + 1))
poz += 2;
if (poz + 1 <= n) {
if (isOnLine(2, 3, poz))
Answer(1, poz + 1, 2, 3);
else
Answer(1, poz, 2, 3);
} else
Answer(1, 5, 2, 3);
} else {
if (isOnLine(1, 2, 4))
Answer(1, 2, 3, 5);
if (isOnLine(1, 2, 5))
Answer(1, 2, 3, 4);
if (isOnLine(1, 3, 4))
Answer(1, 3, 2, 5);
if (isOnLine(1, 3, 5))
Answer(1, 3, 2, 4);
if (isOnLine(2, 3, 5))
Answer(1, 4, 2, 3);
if (isOnLine(2, 4, 5))
Answer(1, 3, 2, 4);
if (isOnLine(3, 4, 5))
Answer(1, 2, 3, 4);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |