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 "meetings.h"
using namespace std;
typedef pair <int, int> pii;
void f(int p, vector <int> &V)
{
vector <int> X;
vector <pii> Y;
int i, j, v, q;
swap(V[rand() % V.size()], V.back());
q = V.back(); V.pop_back();
for(int &t: V){
v = Query(p, q, t);
if(t == v) X.push_back(t);
else Y.emplace_back(v, t);
}
if(X.empty()) Bridge(p, q);
else{
sort(X.begin(), X.end(), [&](int &a, int &b){
if(a == b) return false;
return Query(p, a, b) == a;
});
Bridge(p, X[0]);
for(i=1; i<X.size(); i++){
Bridge(X[i - 1], X[i]);
}
Bridge(X.back(), q);
}
sort(Y.begin(), Y.end());
for(i=0; i<Y.size(); i=j){
V.clear();
for(j=i; j<Y.size() && Y[j].first == Y[i].first; j++){
V.push_back(Y[j].second);
}
f(Y[i].first, V);
}
}
void Solve(int n)
{
vector <int> V;
int i;
srand(time(0));
for(i=1; i<n; i++){
V.push_back(i);
}
f(0, V);
}
Compilation message (stderr)
meetings.cpp: In function 'void f(int, std::vector<int>&)':
meetings.cpp:32:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=1; i<X.size(); i++){
~^~~~~~~~~
meetings.cpp:40:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0; i<Y.size(); i=j){
~^~~~~~~~~
meetings.cpp:42:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=i; j<Y.size() && Y[j].first == Y[i].first; j++){
~^~~~~~~~~
# | 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... |