started reading the book
This commit is contained in:
30
convex_hull.cpp
Normal file
30
convex_hull.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "bits/stdc++.h"
|
||||
using namespace std;
|
||||
|
||||
bool left_side(pair<int, int> &a, pair<int, int> &b, pair<int, int> &x) {
|
||||
return (b.first - a.first)*(x.second - a.second) - (b.second - a.second) * (x.first - a.first) >= 0;
|
||||
}
|
||||
|
||||
|
||||
vector<pair<pair<int, int>, pair<int, int>>> slow_convex_hull(vector<pair<int, int>> &input) {
|
||||
vector<pair<pair<int, int>, pair<int, int>>> output;
|
||||
for (int i{}; i < input.size(); i++) {
|
||||
for (int j = i +1; j < input.size(); j++) {
|
||||
bool valid = true;
|
||||
for (int k{}; k < input.size(); k++) {
|
||||
if (left_side(input[i], input[j], input[k])) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (valid) {
|
||||
output.emplace_back(input[i], input[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cout << "test";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user