Advertisement
Guest User

Untitled

a guest
May 26th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <sstream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <map>
  10. #include <unordered_map>
  11. #include <unordered_set>
  12.  
  13. using namespace std;
  14.  
  15. struct Point {
  16. int x, y;
  17. };
  18.  
  19. int main()
  20. {
  21. ifstream fin;
  22. fin.open("input.txt");
  23. size_t N;
  24. fin >> N;
  25. vector<Point> points(N);
  26. for (size_t i = 0; i < N; i++)
  27. fin >> points[i].x >> points[i].y;
  28. fin.close();
  29.  
  30. bool IsOneLine = true;
  31. for (size_t i = 2; i < N; ++i)
  32. if (0.5 * ((points[i - 2].x - points[i].x) * (points[i - 1].y - points[i].y) -
  33. (points[i - 1].x - points[i].x) * (points[i - 2].y - points[i].y)) != 0) {
  34. IsOneLine = false;
  35. break;
  36. }
  37. fstream fout;
  38. fout.open("output.txt", ios::out);
  39.  
  40. if (IsOneLine)
  41. fout << "yes";
  42. else
  43. fout << "no";
  44. fout.close();
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement