ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1111. Squares

WA on #test 1
Posted by abid1729 18 Aug 2019 01:04
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N,a[55],b[55],i,c[55],j,d[55],e[55],m,n;
    unsigned long long x,y,arr[55];
    cin>>N;
    for(i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        e[i]=i;
    }
    cin>>m>>n;
    for(i=0;i<N;i++){
        x=max(a[i]-m,m-c[i]);
        if(x<0){
            x=0;
        }
        y=max(b[i]-n,n-d[i]);
        if(y<0){
            y=0;
        }
        arr[i]=x*x+y*y;
    }
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            if(arr[i]>a[j]){
                arr[i]=arr[j];
                e[i]=e[j];
            }
        }
    }
        for(i=0;i<N;i++){
            cout<<e[i]+1<<endl;
        }

    return 0;
}