# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
776273 | NK_ | Highway design (CEOI12_highway) | C++17 | 2 ms | 1364 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.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "office.h"
using namespace std;
#define nl '\n'
// g++ -std=c++17 office.cpp A.cpp
int main() {
cin.tie(0)->sync_with_stdio(0);
int N = GetN();
if (isOnLine(1, 2, 3)) {
vector<int> I; for(int i = 3; i < N; i++) I.push_back(i);
int a1 = 1, b1 = 2;
int a2 = -1, b2 = -1;
for(int i = 0; i < int(size(I)); i += 2) {
int a = I[i], b = I[i+1];
if (!isOnLine(a1, a + 1, b + 1)) {
if (isOnLine(a1, b1, a)) {
if (a2 == -1) a2 = b;
else b2 = b;
} else {
if (a2 == -1) a2 = a;
else b2 = a;
}
if (a2 != -1 && b2 != -1) break;
}
}
if (b2 == -1) {
assert(size(I) % 2);
b2 = I.back();
}
Answer(a1, b1, a2, b2);
} else if (isOnLine(1, 4, 5)) {
vector<int> I; for(int i = 1; i < N; i++) if (i != 3 && i != 4) I.push_back(i);
int a1 = 1, b1 = 4;
int a2 = -1, b2 = -1;
for(int i = 0; i < int(size(I)); i += 2) {
int a = I[i], b = I[i+1];
if (a == 1 || !isOnLine(a1, a + 1, b + 1)) {
if (isOnLine(a1, b1, a)) {
if (a2 == -1) a2 = b;
else b2 = b;
} else {
if (a2 == -1) a2 = a;
else b2 = a;
}
if (a2 != -1 && b2 != -1) break;
}
}
if (b2 == -1) {
assert(size(I) % 2);
b2 = I.back();
}
Answer(a1, b1, a2, b2);
} else if (isOnLine(2, 4, 5)) {
int a1 = 2, b1 = 4;
int a2 = 1, b2 = -1;
vector<int> I; for(int i = 5; i < N; i++) I.push_back(i);
for(int i = 0; i < int(size(I)); i += 2) {
int a = I[i], b = I[i+1];
if (!isOnLine(a1, a + 1, b + 1)) {
if (isOnLine(a1, b1, a)) {
if (a2 == -1) a2 = b;
else b2 = b;
} else {
if (a2 == -1) a2 = a;
else b2 = a;
}
if (a2 != -1 && b2 != -1) break;
}
}
if (b2 == -1) {
assert(size(I) % 2);
b2 = I.back();
}
Answer(a1, b1, a2, b2);
} else {
int a1, b1, a2, b2;
set<int> S = {0, 1, 2, 3, 4};
for(int i = 0; i < 5; i++) {
for(int j = i+1; j < 5; j++) {
for(int k = j+1; k < 5; k++) {
if (isOnLine(i + 1, j + 1, k + 1)) {
a1 = i + 1, b1 = j + 1;
S.erase(i); S.erase(j); S.erase(k);
a2 = *begin(S) + 1, b2 = *rbegin(S) + 1;
}
}
}
}
Answer(a1, b1, a2, b2);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |