crowulll

Untitled

Aug 18th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. using namespace std;
  5. int n, sx, sy;
  6. int main(){
  7.     cin >> n >> sx >> sy;
  8.     vector<int> l(5, 0); l[0] = -1;
  9.     for (int i = 0; i < n; ++i){
  10.         int x; int y;
  11.         cin >> x; cin >> y;
  12.         if ((x > sx) && (y > sy)){
  13.             l[1]++;
  14.             l[2]++;
  15.         }
  16.         if ((x < sx) && (y > sy)){
  17.             l[1]++;
  18.             l[4]++;
  19.         }
  20.         if ((x < sx) && (y < sy)){
  21.             l[4]++;
  22.             l[3]++;
  23.         }
  24.         if ((x > sx) && (y < sy)){
  25.             l[2]++;
  26.             l[3]++;
  27.         }
  28.         if ((x == sx) && (y > sy)) l[1]++;
  29.         if ((y < sy) && (x == sx)) l[3]++;
  30.         if ((x > sx) && (y == sy)) l[2]++;
  31.         if ((x < sx) && (y == sy)) l[4]++;
  32.     }
  33.     int pos; int m = -1;
  34.     for (int i = 1; i < 5; ++i){
  35.        if (l[i] >= m){
  36.          m = l[i];
  37.          pos = i;
  38.     }
  39.  
  40.     }
  41.     cout << m << endl;
  42.     if (pos == 1)
  43.         cout << sx << " " << sy + 1;
  44.     else if (pos == 2)
  45.         cout << sx + 1 << " " << sy;
  46.     else if (pos == 3)
  47.         cout << sx << " " << sy - 1;
  48.     else if (pos == 4)
  49.         cout << sx - 1 << " " << sy;
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment