#include "meetings.h"
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int maxN = 2e3 + 326;
vector<int> adj[maxN];
void addEdge(int a, int b){
if(a > b) Bridge(b, a);
else Bridge(a, b);
}
void solve(vector<int> vec){
if(vec.size() == 1) return;
if(vec.size() == 2){
addEdge(vec[0], vec[1]);
return;
}
//cout << "vec = "; for(int x : vec) cout << x << " "; cout << endl;
map<int, vector<int>> mp;
vector<int> nv = vector<int>();
mp[vec[1]] = mp[vec[0]] = vector<int>();
mp[vec[0]].push_back(vec[0]);
mp[vec[1]].push_back(vec[1]);
for(int i = 2; i < vec.size(); i++){
int res = Query(vec[0], vec[1], vec[i]);
if(!mp.count(res)) mp[res] = vector<int>();
mp[res].push_back(vec[i]);
}
for(auto [x, v] : mp){
//cout << "x = " << x << ", v = "; for(int y : v) cout << y << " "; cout << endl;
solve(v);
if(x != vec[0] && x != vec[1]) nv.push_back(x);
}
sort(nv.begin(), nv.end(), [&](int a, int b){
return Query(vec[0], a, b) == a;
});
//cout << "OK\n";
//cout << "nv = " << nv.size() << ", vec: " << vec.size() << endl;
if(nv.size()){
for(int i = 0; i < nv.size() - 1; i++) addEdge(nv[i], nv[i + 1]);
addEdge(vec[0], nv[0]);
addEdge(vec[vec.size() - 1], nv[nv.size() - 1]);
} else addEdge(vec[0], vec[1]);
}
void Solve(int N){
vector<int> jizz = vector<int>();
for(int i = 0; i < N; i++) jizz.push_back(i);
solve(jizz);
}
Compilation message
meetings.cpp: In function 'void solve(std::vector<int>)':
meetings.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i = 2; i < vec.size(); i++){
| ~~^~~~~~~~~~~~
meetings.cpp:32:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
32 | for(auto [x, v] : mp){
| ^
meetings.cpp:37:2: error: 'sort' was not declared in this scope; did you mean 'qsort'?
37 | sort(nv.begin(), nv.end(), [&](int a, int b){
| ^~~~
| qsort
meetings.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i = 0; i < nv.size() - 1; i++) addEdge(nv[i], nv[i + 1]);
| ~~^~~~~~~~~~~~~~~