This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include "meetings.h"
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 2005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = INT_MAX;
vec < pii > eds;
int A,n,vz[nmax];
vector<int>vc[nmax];
/*int Query(int x,int y,int z)
{
cout<<"Q "<<x<<" "<<y<<" "<<z<<endl;
int rs;
cin>>rs;
return rs;
}*/
bool cmp(int x,int y)
{
return Query(A,x,y)==x;
}
void solves(vec <int> tb){
if(tb.size() == 1)return ;
if(tb.size()==2)
{
eds.pb({tb[0],tb[1]});
return;
}
srand(time(0));
for(int i:tb)vc[i].clear(),vz[i]=0;
int m=tb.size(),B;
A=B=0;
while(B == A)B = tb[rand()%m],A=tb[rand()%m];
vector<int>pth;
for(int i : tb){
if(i != A && i != B && Query(A,B,i) == i) pth.pb(i);
}
pth.pb(B);
sort(all(pth),cmp);
reverse(all(pth));
pth.pb(A);
for(int i=1;i<pth.size();i++)eds.pb({pth[i-1],pth[i]});
for(int i=0;i<pth.size();i++)vz[pth[i]]=1,vc[pth[i]].pb(pth[i]);
for(int i : tb){
if(!vz[i])
{
vc[Query(A,B,i)].pb(i);
}
}
for(int i=0;i<pth.size();i++)
{
solves(vc[pth[i]]);
}
}
void Solve(int n)
{
vec < int > asd;
for(int i= 0; i <n ;i++)asd.pb(i);
solves(asd);
for(pii ed : eds){
Bridge(min(ed.fr,ed.sc),max(ed.fr,ed.sc));
}
}
/*int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n;
return 0;
}*/
Compilation message (stderr)
meetings.cpp: In function 'void solves(std::vector<int>)':
meetings.cpp:61:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<pth.size();i++)eds.pb({pth[i-1],pth[i]});
~^~~~~~~~~~~
meetings.cpp:62:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<pth.size();i++)vz[pth[i]]=1,vc[pth[i]].pb(pth[i]);
~^~~~~~~~~~~
meetings.cpp:69:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<pth.size();i++)
~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |