# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125182 | figter001 | Highway design (CEOI12_highway) | C++17 | 0 ms | 0 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"
#define _MaxN 100001
using namespace std;
// bool _Init = true;
// int _digi = 129723562;
// int _N, _Qnum, _maxQ1, _maxQ2, _maxQ4;
// int _Apa[_MaxN];
// void _Fin(bool OK, string S){
// int point=0;
// if (OK) {
// if (_Qnum <= _maxQ4) {
// point = 4;
// S=" <=N/2+2";
// } else if (_Qnum <= _maxQ2) {
// point = 2;
// S=" <=2N/3";
// } else {
// point = 1;
// S=" <=N-3";
// }
// cout<<point<<endl;
// cout<<"Correct"<<endl;
// cout<<"#Questions= "<<_Qnum<<S<<endl;
// cout<<_digi<<endl;
// exit(0);
// }
// cout<<"0"<<endl;
// cout<<S<<endl;
// cout<<"#Questions= "<<_Qnum<<endl;
// cout<<_digi<<endl;
// exit(0);
// } /*_Fin*/
// void _doInit(){
// int x;
// cin>>_N;
// for (x = 1; x <= _N; x++) {
// _Apa[x] = -1;
// }
// _Qnum = 0;
// _maxQ1 = _N - 3;
// _maxQ2 = _N * 2 / 3;
// _maxQ4 = _N / 2+2;
// } /*diInit*/
// int GetN(){
// if (_Init) {
// _doInit();
// _Init = false;
// }
// return _N;
// } /*GetN*/
// int _Find(int x){
// int k;
// int Nx = x;
// while (_Apa[Nx] > 0) {
// Nx = _Apa[Nx];
// }
// while (x != Nx) {
// k = _Apa[x];
// _Apa[x] = Nx;
// x = k;
// }
// return Nx;
// } /*_Find*/
// int _Unio(int nn, int mm){
// int k;
// if (nn == mm) {
// return nn;
// }
// if (_Apa[nn] > _Apa[mm]) {
// k = nn;
// nn = mm;
// mm = k;
// }
// _Apa[nn] += _Apa[mm];
// _Apa[mm] = nn;
// return nn;
// } /*_Unio*/
// int isOnLine(int x, int y, int z){
// int nx, ny, nz,nn;
// int nxn = 0, nyn = 0, nzn = 0;
// int i;
// if (_Init) {
// _Fin(0, "Protocol error");
// }
// if (x < 1 || x > _N || y < 1 || y > _N || z < 1 || z > _N) {
// _Fin(0, "Protocol error");
// }
// _Qnum++;
// if (_Qnum > _maxQ1)
// _Fin(false, "Too many questions");
// if (x == y || y == z || y==z) {
// return 1;
// }
// nx = _Find(x);
// ny = _Find(y);
// nz = _Find(z);
// if (nx == ny && ny == nz) {
// return 1;
// }
// nxn = -_Apa[nx]; nyn = -_Apa[ny]; nzn = -_Apa[nz];
// nn=nxn+nyn+nzn;
// if (nx==ny) nn-=nyn;
// if (nx==nz) nn-=nzn;
// if (ny==nz) nn-=nzn;
// if (nn <= _N - 3) {
// nx = _Unio(nx, ny);
// nx = _Unio(nx, nz);
// return 1;
// }
// return 0;
// } /*isOnLine*/
bool vis[11][11][11];
void Answer(int a1, int b1, int a2, int b2){
int n = GetN();
vector<int> a = {1,2,3,4,5};
do{
vector<int> cur;
cur.push_back(a[0]);
cur.push_back(a[1]);
cur.push_back(a[2]);
sort(cur.begin(),cur.end());
int x = cur[0],y = cur[1],z = cur[2];
if(vis[x][y][z])continue;
vis[x][y][z] = 1;
int res = isOnLine(x,y,z);
if(res == 1){
Answer(x,y,cur[3],cur[4]);
return;
}
}while(next_permutation(a.begin(),a.end()));
}