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;
mt19937 rd = mt19937((unsigned)chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> ran(0, 2147483647);
int s,t;
bool comp(int a,int b) {
if (a==b) {
return false;
}
if (Query(a,b,t)==b) {
return true;
}
else {
return false;
}
}
void f(vector<int> v) {
if (v.size()==1) {
return;
}
int one=ran(rd)%v.size();
int two=ran(rd)%v.size();
while (one==two) {
two=ran(rd)%v.size();
}
vector<int> save(v.size());
for(int i=0;i<v.size();i++) {
if (i!=one&&i!=two) {
save[i]=Query(v[one],v[two],v[i]);
}
}
save[one]=v[one];
save[two]=v[two];
vector<int> vec;
for(int i=0;i<v.size();i++) {
if (i!=one&&i!=two&&save[i]==v[i]) {
vec.push_back(v[i]);
}
}
s=v[one];
t=v[two];
sort(vec.begin(),vec.end(),comp);
vec.insert(vec.begin(),v[one]);
vec.push_back(v[two]);
for(int i=0;i+1<vec.size();i++) {
Bridge(min(vec[i],vec[i+1]),max(vec[i],vec[i+1]));
}
vector<vector<int>> val(vec.size());
for(int i=0;i<v.size();i++) {
for(int j=0;j<vec.size();j++) {
if (save[i]==vec[j]) {
val[j].push_back(v[i]);
break;
}
}
}
for(int i=0;i<vec.size();i++) {
f(val[i]);
}
}
void Solve(int n) {
mt19937 rd = mt19937((unsigned)chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> ran(0, 2147483647);
vector<int> vec;
for(int i=0;i<n;i++) {
vec.push_back(i);
}
f(vec);
}
Compilation message (stderr)
meetings.cpp: In function 'void f(std::vector<int>)':
meetings.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int i=0;i<v.size();i++) {
| ~^~~~~~~~~
meetings.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0;i<v.size();i++) {
| ~^~~~~~~~~
meetings.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int i=0;i+1<vec.size();i++) {
| ~~~^~~~~~~~~~~
meetings.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i=0;i<v.size();i++) {
| ~^~~~~~~~~
meetings.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int j=0;j<vec.size();j++) {
| ~^~~~~~~~~~~
meetings.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i=0;i<vec.size();i++) {
| ~^~~~~~~~~~~
meetings.cpp: In function 'void Solve(int)':
meetings.cpp:67:13: warning: variable 'rd' set but not used [-Wunused-but-set-variable]
67 | mt19937 rd = mt19937((unsigned)chrono::steady_clock::now().time_since_epoch().count());
| ^~
# | 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... |