Add a bunch of other problems
This commit is contained in:
@@ -0,0 +1,206 @@
|
||||
/* Problem URL: https://codeforces.com/contest/961/problem/D */
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
template <class T, class comp = less<>>
|
||||
using ordered_set = tree<T, null_type , comp , rb_tree_tag , tree_order_statistics_node_update>;
|
||||
|
||||
#define V vector
|
||||
|
||||
#define rmin(a, b) a = min(a, b)
|
||||
#define rmax(a, b) a = max(a, b)
|
||||
|
||||
#define rep(i, lim) for (int i = 0; i < (lim); i++)
|
||||
#define nrep(i, s, lim) for (int i = s; i < (lim); i++)
|
||||
|
||||
#define repv(i, v) for (auto &i : (v))
|
||||
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
|
||||
#define sortv(v) sort(v.begin(), v.end())
|
||||
#define all(v) (v).begin(), (v).end()
|
||||
|
||||
using vi = vector<int>;
|
||||
using vvi = vector<vi>;
|
||||
using vvvi = vector<vvi>;
|
||||
using vvvvi = vector<vvvi>;
|
||||
|
||||
using ll = long long;
|
||||
|
||||
using vl = vector<ll>;
|
||||
using vvl = vector<vl>;
|
||||
using vvvl = vector<vvl>;
|
||||
using vvvvl = vector<vvvl>;
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
|
||||
os << vec[0];
|
||||
for (size_t i = 1; i < vec.size(); i++) {
|
||||
os << ' ' << vec[i];
|
||||
}
|
||||
os << '\n';
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<v> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
is >> i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
|
||||
for (auto &i : vec) {
|
||||
os << i[0];
|
||||
for (size_t j = 1; j < i.size(); j++) {
|
||||
os << ' ' << i[j];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class v>
|
||||
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
|
||||
for (auto &i : vec) {
|
||||
for (auto &j : i) {
|
||||
is >> j;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
// Geometria
|
||||
|
||||
typedef long long ld;
|
||||
const ld DINF = 1e18;
|
||||
const ld pi = acos(-1.0);
|
||||
const ld eps = 1e-9;
|
||||
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
bool eq(ld a, ld b) {
|
||||
return abs(a - b) <= eps;
|
||||
}
|
||||
|
||||
struct pt { // ponto
|
||||
ld x, y;
|
||||
pt(ld x_ = 0, ld y_ = 0) : x(x_), y(y_) {}
|
||||
bool operator < (const pt p) const {
|
||||
if (!eq(x, p.x)) return x < p.x;
|
||||
if (!eq(y, p.y)) return y < p.y;
|
||||
return 0;
|
||||
}
|
||||
bool operator == (const pt p) const {
|
||||
return eq(x, p.x) and eq(y, p.y);
|
||||
}
|
||||
pt operator + (const pt p) const { return pt(x+p.x, y+p.y); }
|
||||
pt operator - (const pt p) const { return pt(x-p.x, y-p.y); }
|
||||
pt operator * (const ld c) const { return pt(x*c , y*c ); }
|
||||
pt operator / (const ld c) const { return pt(x/c , y/c ); }
|
||||
ld operator * (const pt p) const { return x*p.x + y*p.y; }
|
||||
ld operator ^ (const pt p) const { return x*p.y - y*p.x; }
|
||||
friend istream& operator >> (istream& in, pt& p) {
|
||||
return in >> p.x >> p.y;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
if (n <= 3) {
|
||||
cout << "YES\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
V<pt> a(n);
|
||||
cin >> a;
|
||||
|
||||
V<bool> group(n);
|
||||
V<bool> invalid(n);
|
||||
|
||||
auto iscol = [&](pt a, pt b, pt c) {
|
||||
return (b.y - a.y) * (c.x - b.x) == (c.y - b.y) * (b.x - a.x);
|
||||
};
|
||||
|
||||
auto check = [&]() {
|
||||
int first = 0;
|
||||
while (group[first]) {
|
||||
first++;
|
||||
}
|
||||
|
||||
int second = first + 1;
|
||||
while (group[second]) {
|
||||
second++;
|
||||
}
|
||||
|
||||
rep(i, n) {
|
||||
if (group[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!iscol(a[first], a[second], a[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
int c = 0;
|
||||
|
||||
rep(i, n) {
|
||||
if (iscol(a[0], a[1], a[i])) {
|
||||
group[i] = true;
|
||||
} else {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
if (c <= 2 || check()) {
|
||||
cout << "YES\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
fill(all(group), false);
|
||||
c = 0;
|
||||
rep(i, n) {
|
||||
if (iscol(a[0], a[2], a[i])) {
|
||||
group[i] = true;
|
||||
} else {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
if (c <= 2 || check()) {
|
||||
cout << "YES\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
fill(all(group), false);
|
||||
c = 0;
|
||||
rep(i, n) {
|
||||
if (iscol(a[1], a[2], a[i])) {
|
||||
group[i] = true;
|
||||
} else {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
if (c <= 2 || check()) {
|
||||
cout << "YES\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
cout << "NO\n";
|
||||
}
|
||||
Reference in New Issue
Block a user