Advertisement
tepyotin2

#1.1 Dance Party

Dec 9th, 2023
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. struct Pos{
  6.     int x;
  7.     int y;
  8.     Pos(){};
  9.     Pos(int x1, int y1){
  10.         x = x1;
  11.         y = y1;
  12.     };
  13. };
  14.  
  15. int main(){
  16.     ios_base::sync_with_stdio(0), cin.tie(0);
  17.     // freopen("DanceParty.in", "r", stdin);
  18.     int n;
  19.     cin >> n;
  20.     int x, y;
  21.     Pos pos[n];
  22.     for(int i=1; i<=n; i++){
  23.         cin >> x >> y;
  24.         pos[i] = Pos(x, y);
  25.         // cout << pos[i].x << ", " << pos[i].y << '\n';
  26.     }
  27.     int ans1 = 0, ans2 = 0;
  28.     int ax = 0, ay = 0;
  29.     for(int i=1; i<=n; i++){
  30.         for(int j=i+1; j<=n; j++){
  31.             int sx = (pos[i].x-pos[j].x)*(pos[i].x-pos[j].x);
  32.             int sy = (pos[i].y-pos[j].y)*(pos[i].y-pos[j].y);
  33.             // cout << "i: " << i << ", j: " << j << ", pos[i].x: " << pos[i].x << ", pos[i].y: " << pos[i].y << ", pos[j].x: " << pos[j].x << ", pos[j].y: " << pos[j].y << ", sx: " << sx << ", sy: " << sy << '\n';
  34.             // cout << "sx: " << sx << ", sy: " << sy << '\n';
  35.             int ts = sx+sy;
  36.             if(ts>ax+ay){
  37.                 // cout << "i: " << i << ", j: " << j << ", ts: " << ts << ", ax+ay: " << ax+ay << '\n';
  38.                 ax = sx;
  39.                 ay = sy;
  40.                 ans1 = i;
  41.                 ans2 = j;
  42.             }
  43.         }
  44.     }
  45.     cout << ans1 << " " << ans2 << '\n';
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement