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

AC, no problem ;-)
Posted by Ilya Mitin (2) 28 Jun 2008 17:46
if you get WA1 or WA2 try to test:

3
0 0 1 1
0 3 1 4
4 2 4 4
3 1

right answer = 3 1 2
._
|_|
.
...../\
.....\/
._
|_|
.

This is square but not rectangle! ;)
I used simple geometric from

http://hardfire.jino-net.ru/index.php?id=77&cp=40563b52a55df6f5dfc9732f78ae175b

Good luks! :)

Edited by author 29.06.2008 14:30
Re: AC, no problem ;-)
Posted by Junk 10 Aug 2009 17:16
thx for test
Re: AC, no problem ;-)
Posted by abid1729 18 Aug 2019 11:48
my code passed yours test but shows WA1

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N,a[55],b[55],i,c[55],j,d[55],t,e[55],m,n;
    unsigned long long x,y,p,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]){
                p=arr[i];
                arr[i]=arr[j];
                arr[j]=p;
                t=e[i];
                e[i]=e[j];
                e[j]=t;
            }
        }
    }
        for(i=0;i<N;i++){
            cout<<e[i]+1<<" ";
        }

    return 0;
}