f.nasim's blog

By f.nasim, 14 years ago, In English
/*
Can anyone tell me what's wrong in the following code. It is repeatedly getting "Wrong answer on test 4".
*/

#include<iostream>
#include<cmath>

using namespace std;

long long max(long long x, long long y)
{
    if(x>y)
        return x;

    return y;
}

long long min(long long x, long long y)
{
    if(x<y)
        return x;

    return y;
}

int main()
{
    long long t,n,m,x1,y1,x2,y2,p,q,r,s;

    cin >> t;

    while(t--)
    {
        cin >> n >> m >> p >> q >> r >> s;

        x1=y1=1;
        x2=fabs(p-r)+1;
        y2=fabs(q-s)+1;

        if(x2==n && y2==m)
        {
            cout << m*n-2 << endl;
            continue;
        }

        long long rbound=n-fabs(x2-x1);
        long long bbound=m-fabs(y2-y1);

        long long maxx=max(x1,x2);
        long long maxy=max(y1,y2);

        long long over=(rbound-maxx+1)*(bbound-maxy+1);
        long long count=(rbound*2)*bbound;
        long long tot=count-over;

        cout << (m*n)-tot << endl;
    }

    return 0;
}

  • Vote: I like it
  • 0
  • Vote: I do not like it

14 years ago, # |
  Vote: I like it +4 Vote: I do not like it
WA 4 can be just anything, because it is a multi-test.
Consider copy-pasting some accepted solution and comparing outputs on a random set of tests.
  • 14 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it
    Yes, it worked. I got a case, handled that and now got accepted. Thanks for your suggestion.
14 years ago, # |
  Vote: I like it 0 Vote: I do not like it
how can we see somebody else's accepted solution??it just shows that the solution is accepted in the standings section