# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39829 | cheater2k | Highway design (CEOI12_highway) | C++14 | 2 ms | 3264 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 <bits/stdc++.h>
#include "office.h"
using namespace std;
int n, a, b, c;
int query(int x, int y, int z) {
return isOnLine(x + 1, y + 1, z + 1);
}
void brute() {
for (a = 0; a < 5; ++a) {
for (b = a + 1; b < 5; ++b) {
for (c = b + 1; c < 5; ++c) {
if (!query(a, b, c)) continue;
int x = 0;
while(x == a || x == b || x == c) ++x;
int y = 10 - a - b - x;
Answer(a + 1, b + 1, x + 1, y + 1);
}
}
}
}
void solve() {
vector<int> line;
vector<int> rem;
for (int i = 0; i < n; ++i) if (i != a && i != b && i != c) rem.push_back(i);
for (int i = 0; i < rem.size(); i += 2) {
if (line.size() >= 2) break;
int x = rem[i], y = (i == rem.size() - 1) ? b : rem[i + 1];
if (query(a, x, y)) continue;
if (!query(a, b, x)) {
line.push_back(x);
} else {
line.push_back(y);
}
}
assert(line.size() >= 2);
Answer(a + 1, b + 1, line[0] + 1, line[1] + 1);
}
int main() {
n = GetN();
a = -1, b = -1, c = -1;
int p = query(0, 1, 2);
if (p) {
a = 0; b = 1; c = 2; solve();
}
int q = query(2, 3, 4);
if (q) {
a = 2; b = 3; c = 4; solve();
}
brute();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |