Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. struct Point
  4. {
  5.     int x;
  6.     int y;
  7. };
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     std::cin >> n;
  13.  
  14.     Point deviants[2];
  15.     std::cin >> deviants[0].x;
  16.     std::cin >> deviants[0].y;
  17.  
  18.     std::cin >> deviants[1].x;
  19.     std::cin >> deviants[1].y;
  20.  
  21.     bool vertical = false;
  22.     int k = 0, a = 0;
  23.     if (deviants[0].x != deviants[1].x)
  24.     {
  25.         k = (deviants[1].y - deviants[0].y) / (deviants[1].x - deviants[0].x);
  26.         a = (deviants[0].y + deviants[1].y - k * (deviants[0].x + deviants[1].x)) / 2;
  27.     }
  28.     else
  29.     {
  30.         vertical = true;
  31.         k = deviants[0].x;
  32.     }
  33.  
  34.     int index = -1;
  35.     Point input;
  36.     for (int i = 2; i < n; i++)
  37.     {
  38.         std::cin >> input.x;
  39.         std::cin >> input.y;
  40.  
  41.         if (index != -1)
  42.             continue;
  43.  
  44.         if ((!vertical && k * input.x + a != input.y) || (vertical && input.x != k))
  45.             index = i + 1;
  46.     }
  47.  
  48.     if (index != -1)
  49.     {
  50.         std::cout << "Yes" << std::endl;
  51.         std::cout << 1 << " " << 2 << " " << index;
  52.     }
  53.     else
  54.     {
  55.         std::cout << "No" << std::endl;
  56.     }
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement