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 1373. Pictura ex Machina

WA #8
Posted by Lebedev_Nicolay[Ivanovo SPU] 26 Jul 2009 22:56
I have Wa #8 many times, I don't know what's wrong!!! Can anybody check my code or give me a hint?
Re: WA #8
Posted by Lebedev_Nicolay[Ivanovo SPU] 30 Jul 2009 19:45
There is my code, I still have WA #8:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
    double x1, x2, y1, y2, Right = -1e9, Left = 1e9, Up = -1e9, Down = 1e9;

    double x3, y3, x0, y0, n, m;

    int N = 0;

    while (cin >> x1 >> y1 >> x2 >> y2)
    {
        N ++;
        x0 = (x1 + x2) / 2.0;
        y0 = (y1 + y2) / 2.0;

        n = x1 - x0;
        m = y1 - y0;
        x3 = m + x0;
        y3 = -n + y0;

        Left = min(Left, min(x1, min(x2, x3)));
        Right = max(Right, max(x1, max(x2, x3)));
        Up = max(Up, max(y1, max(y2, y3)));
        Down = min(Down, min(y1, min(y2, y3)));

    }

    if (N == 0) printf("%0.4f %0.4f", 0, 0);
    else printf("%0.4f %0.4f", fabs(Right - Left), fabs(Up - Down));

    return 0;
}
Re: WA #8
Posted by Oleg Strekalovsky [Vologda SPU] 31 Oct 2010 23:45
Try empty input.
If you use Java - don't use Scanner.
His hasNextDouble()/hasNextInt(), nextDouble()/nextInt() are too slow for large input.
Use StreamTokenizer.

Edited by author 31.10.2010 23:46