# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286389 | Kastanda | Highway design (CEOI12_highway) | C++11 | 1 ms | 768 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.
// M
#include<bits/stdc++.h>
#include "office.h"
using namespace std;
const int N = 100005;
int main()
{
int n = GetN();
if (isOnLine(1, 2, 3))
{
vector < int > vec;
for (int i = 4; i + 1 <= n && (int)vec.size() <= 1; i += 2)
if (!isOnLine(1, i, i + 1))
vec.push_back(i);
if ((int)vec.size() == 2)
{
int a = vec[0] + (int)isOnLine(1, 2, vec[0]);
int b = vec[1] + (int)isOnLine(1, 2, vec[1]);
Answer(1, 2, a, b);
return 0;
}
assert((int)vec.size());
if (n % 2 == 1)
{
Answer(1, 2, vec[0], vec[0] + 1);
return 0;
}
if (isOnLine(1, 2, vec[0]))
{
Answer(1, 2, vec[0] + 1, n);
return 0;
}
if (isOnLine(1, 2, vec[0] + 1))
{
Answer(1, 2, vec[0], n);
return 0;
}
Answer(1, 2, vec[0], vec[0] + 1);
return 0;
}
int traitor = -1;
if (isOnLine(1, 2, 4))
traitor = 3;
else if (isOnLine(1, 3, 4))
traitor = 2;
else if (isOnLine(2, 3, 4))
traitor = 1;
if (traitor == -1)
{
for (int i = 1; i <= 4; i ++)
for (int j = i + 1; j <= 4; j ++)
if (isOnLine(i, j, 5))
{
int a = 1;
while (a == i || a == j)
a ++;
int b = a + 1;
while (b == i || b == j)
b ++;
Answer(i, j, a, b);
return 0;
}
}
int good_samaritan_1 = (traitor == 1) ? 2 : 1;
int good_samaritan_2 = (traitor <= 2) ? 3 : 2;
vector < int > vec;
for (int i = 5; i + 1 <= n && !(int)vec.size(); i += 2)
if (!isOnLine(good_samaritan_1, i, i + 1))
vec.push_back(i);
if (!(int)vec.size())
{
assert(n % 2 == 1);
Answer(good_samaritan_1, good_samaritan_2, traitor, n);
return 0;
}
if (isOnLine(good_samaritan_1, good_samaritan_2, vec[0]))
Answer(good_samaritan_1, good_samaritan_2, traitor, vec[0] + 1);
else
Answer(good_samaritan_1, good_samaritan_2, traitor, vec[0]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |