ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1767. Дом доктора Ди

WA#17
Послано sklyack 12 апр 2010 02:28
Have anybogy gotten?
Re: WA#17
Послано sklyack 12 апр 2010 03:14
I shocked... when I input/output like this
...
scanf("%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d", &x01, &y01, &x1, &y1, &x02, &y02, &x2, &y2);
...
printf("%I64d", intersect);
...

I got WA#17, and when I instead of that wrote this
...
cin>>x01>>y01>>x1>>y1>>x02>>y02>>x2>>y2;
...
cout<<intersect;
...

I got AC! Why? Doesn't the "scanf" correctly read __int64 numbers?
P.S. Sorry for my english.
Re: WA#17
Послано Ego 12 апр 2010 23:32
i used scanf. it works
scanf("%I64d%I64d\n%I64d%I64d\n%I64d%I64d\n%I64d%I64d", &x11,&y11, &x12,&y12, &x21,&y21, &x22,&y22);
Re: WA#17
Послано sklyack 12 апр 2010 23:45
I tried scanf with "\n" -- the same verdict: WA#17

Edited by author 12.04.2010 23:46
Re: WA#17
Послано Ego 13 апр 2010 00:47
if all of x01, y01, x1, y1, x02, y02, x2, y2 are 64bit integers (long long or __int64) then i don't know. strange..
Re: WA#17
Послано Baurzhan 13 апр 2010 12:59
May be your "intersection" variable either float or double but you print it like 64-bit integer.
Try this: printf("%lld", intersect);
Re: WA#17
Послано sklyack 14 апр 2010 01:05
Baurzhan писал(a) 13 апреля 2010 12:59
May be your "intersection" variable either float or double but you print it like 64-bit integer.
Try this: printf("%lld", intersect);
It gets WA#1.
All of variables x01, y01, x1, y1, x02, y02, x2, y2, intersect, have type "long long", so output by
printf("%I64d", intersect);
must be correct, but it isn't so.

Edited by author 14.04.2010 01:06

Edited by author 14.04.2010 01:07
Re: WA#17
Послано sklyack 14 апр 2010 01:17
If you want, I can send my code on your e-mail, if you got AC, and you will be able to check this phenomenon.
Re: WA#17
Послано Ego 14 апр 2010 08:12
that would be interesting to look at it. accdead@gmail.com
Re: WA#17
Послано sklyack 14 апр 2010 22:49
sent.
Re: WA#17
Послано ONU_Antananarivu 20 май 2010 21:20
I also got WA#17
I don't know what to do
Give me some tests please or tell what in my code is wrong

#include <iostream>
using namespace std;

struct Coord
{
    __int64 x;
    __int64 y;
};

bool Sign(__int64 x, __int64 y)
{
    if(x > y)
        return 1;
    return 0;
}

void Sort(Coord* arr)
{
    for(int i = 0; i < 4; i++)
    {
        for(int j = i; j < 4; j++)
        {
            if((arr[j].x < arr[i].x) || (arr[j].x == arr[i].x && arr[j].y > arr[i].y))
            {
                Coord tmp = arr[j];
                arr[j] = arr[i];
                arr[i] = tmp;
            }
        }
    }
}

int main()
{
    Coord crd[4];

    for(int i = 0; i < 4; i++)
    {
        cin >> crd[i].x >> crd[i].y;
    }

    bool sign1 = Sign(crd[0].x, crd[1].x) ^ Sign(crd[0].y, crd[1].y);
    bool sign2 = Sign(crd[2].x, crd[3].x) ^ Sign(crd[2].y, crd[3].y);
    __int64 a = -1, b = -1;

    Coord arr[4];
    for(int i = 0; i < 4; i++)
    {
        arr[i].x = crd[i].x;
        if(i < 2)
            arr[i].y = 0;
        else
            arr[i].y = 1;
        if(i % 2 == 1)
        {
            if(arr[i].x < arr[i-1].x)
            {
                __int64 tmp = arr[i].x;
                arr[i].x = arr[i-1].x;
                arr[i-1].x = tmp;
            }
        }
    }
    Sort(arr);
    if(arr[2].y == arr[0].y || arr[2].y == arr[1].y || arr[2].x == arr[0].x || arr[3].x == arr[1].x)
        a = arr[2].x - arr[1].x;


    for(int i = 0; i < 4; i++)
    {
        arr[i].x = crd[i].y;
        if(i < 2)
            arr[i].y = 0;
        else
            arr[i].y = 1;
        if(i % 2 == 1)
        {
            if(arr[i].x < arr[i-1].x)
            {
                __int64 tmp = arr[i].x;
                arr[i].x = arr[i-1].x;
                arr[i-1].x = tmp;
            }
        }
    }
    Sort(arr);
    if(arr[2].y == arr[0].y || arr[2].y == arr[1].y || arr[2].x == arr[0].x || arr[3].x == arr[1].x)
        b = arr[2].x - arr[1].x;



    if(sign1 == sign2)
    {
        cout << a + b << endl;
    }
    else
    {
        if(a == -1 || b == -1)
            cout << 0 << endl;
        if(a > b)
            cout << a << endl;
        else
            cout << b << endl;
    }

    return 0;
}
Re: WA#17
Послано ASK 17 ноя 2010 21:13
It is the first test where rectangle projections do not intersect.