D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))
1 #include <vector> 2 #include <iostream> 3 #include <algorithm> 4 using namespace std; 5 typedef long long ll; 6 const int N = 1e5 + 5; 7 ll x[N], y[N]; 8 int n; 9 10 bool gx(int a, int b, int c, int d) 11 { 12 return (x[b] - x[a])*(y[d] - y[c]) == (x[d] - x[c])*(y[b] - y[a]); 13 } 14 15 int check(int d, int f) 16 { 17 vector<int>q; 18 for (int i = 1; i <= n; i++) 19 if (!gx(d, f, f, i)) 20 q.push_back(i); 21 if (q.size()<3) return 1; 22 for (int i = 2; i<q.size(); i++) 23 if (!gx(q[0],q[1], q[1], q[i])) 24 return 0; 25 return 1; 26 } 27 28 int main() 29 { 30 cin >> n; 31 for (int i = 1; i <= n; i++) 32 cin >> x[i] >> y[i]; 33 if (n<5 || check(1, 2) || check(2, 3) || check(1, 3)) 34 cout << "YES" << endl; 35 else cout << "NO" <<endl; 36 //system("pause"); 37 return 0; 38 }