# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370478 | arnold518 | Highway design (CEOI12_highway) | C++14 | 35 ms | 4196 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 "office.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N;
int GetN(void);
int isOnLine(int x, int y, int z);
void Answer(int a1, int b1, int a2, int b2);
map<tuple<int, int, int>, int> M;
int query(int a, int b, int c)
{
if(a>b) swap(a, b);
if(b>c) swap(b, c);
if(a>b) swap(a, b);
if(M.find({a, b, c})!=M.end()) return M[{a, b, c}];
M[{a, b, c}]=isOnLine(a, b, c);
return M[{a, b, c}];
}
vector<int> V, V3;
vector<pii> V2;
int main()
{
N=GetN();
V.push_back(1);
for(int i=2; i+1<=N; i+=2)
{
if(query(1, i, i+1))
{
V.push_back(i);
V.push_back(i+1);
}
else
{
V2.push_back({i, i+1});
}
}
for(auto it : V2)
{
if(query(V[0], V[1], it.first))
{
V3.push_back(it.second);
}
else
{
V3.push_back(it.first);
if(V3.size()>1 && V.size()>1) break;
if(query(V[0], V[1], it.second))
{
V3.push_back(it.second);
if(V3.size()>1 && V.size()>1) break;
}
}
if(V3.size()>1 && V.size()>1) break;
}
Answer(V[0], V[1], V3[0], V3[1]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |