# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938677 | groshi | Meetings (JOI19_meetings) | 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"meetings.h"
//#include<bits/stdc++.h>
using namespace std;
int N;
/*int Query(int x,int y,int z)
{
cout<<x<<" "<<y<<" "<<z<<": ";
int wynik;
cin>>wynik;
cout<<"\n";
return wynik;
}
void Bridge(int x,int y)
{
cout<<x<<" "<<y<<" buduje\n";
}*/
void dfs(int x,vector<int> Q)
{
if(Q.size()==0)
return;
int strzal=rand()%(Q.size());
strzal=Q[strzal];
//cout<<x<<" "<<strzal<<"\n";
vector<int> sasiad[N],sciezka;
for(int i=0;i<Q.size();i++)
{
if(Q[i]==strzal)
continue;
int mam=Query(x,strzal,Q[i]);
if(mam==Q[i])
sciezka.push_back(Q[i]);
else{
//cout<<"wrzucam "<<mam<<" "<<Q[i]<<"\n";
sasiad[mam].push_back(Q[i]);
}
}
sort(sciezka.begin(),sciezka.end(),[&](int a,int b){return Query(x,a,b)==a;});
sciezka.push_back(strzal);
int pocz=x;
for(int i=0;i<sciezka.size();i++)
{
Bridge(min(pocz,sciezka[i]),max(pocz,sciezka[i]));
pocz=sciezka[i];
}
sciezka.push_back(x);
for(int i=0;i<sciezka.size();i++)
dfs(sciezka[i],sasiad[sciezka[i]]);
}
void Solve(int n)
{
N=n;
int korzen=rand()%n;
vector<int> wszyscy;
for(int i=0;i<n;i++)
if(i!=korzen)
wszyscy.push_back(i);
dfs(korzen,wszyscy);
}