QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#280441#7779. Swiss Stageucup-team1525#WA 0ms3580kbC++204.3kb2023-12-09 16:09:062023-12-09 16:09:07

Judging History

This is the latest submission verdict.

  • [2023-12-09 16:09:07]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3580kb
  • [2023-12-09 16:09:06]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int T;
const int N=100005;
ll h[N],w[N];
int main()
{
    scanf("%d",&T);
    while (T--)
    {
        for (int i=0;i<=3;++i)
            scanf("%lld%lld",&h[i],&w[i]);
        bool b=false;
        for (int i=1;i<=3;++i)
            if (h[0]==h[i]&&w[0]==w[i])
                b=true;
        if (b)
        {
            ll ans=1;
            for (int i=1;i<=3;++i)
                ans=(ll)ans*(h[0]-h[i]+1)%mod*(w[0]-w[i]+1)%mod;
            printf("%lld\n",ans);
            continue;
        }
        vector<int> x,y,z;
        for (int i=1;i<=3;++i)
        {
            if (h[i]==h[0])
                x.push_back(i);
            if (w[i]==w[0])
                y.push_back(i);
        }

        if (x.size()==0)
        {
            if (y.size()==0)
            {
                puts("0");
                continue;
            }
            if (y.size()==1)
            {
                for (int i=1;i<=3;++i)
                    if (i!=y[0])
                        z.push_back(i);
                if (w[z[0]]+w[z[1]]>=w[0]&&min(h[z[0]],h[z[1]])+h[y[0]]>=h[0])
                    puts("4");
                else
                    puts("0");
                continue;
            }
            if (y.size()==2)
            {
                for (int i=1;i<=3;++i)
                    if (i!=y[0])
                        z.push_back(i);
                if (h[y[0]]+h[y[1]]>=h[0])
                    printf("%lld\n",2*(h[0]-h[z[0]]+1)%mod*(w[0]-w[z[0]]+1)%mod);
                else
                    puts("0");
                continue;
            }
            if (y.size()==3)
            {
                if (h[1]+h[2]+h[3]>=h[0])
                {
                    ll ans=0;
                    if (h[1]+h[2]>=h[0])
                        ans+=max(0ll,h[0]-h[3]+1)*2;
                    if (h[1]+h[3]>=h[0])
                        ans+=max(0ll,h[0]-h[2])*2;
                    if (h[2]+h[3]>=h[0])
                        ans+=max(0ll,h[0]-h[1]-1)*2;
                    ans%=mod;
                    printf("%lld\n",ans);
                }
                else
                    puts("0");
                continue;
            }
        }
        if (x.size()==1)
        {
            if (y.size()==0)
            {
                for (int i=1;i<=3;++i)
                    if (i!=x[0])
                        z.push_back(i);
                if (h[z[0]]+h[z[1]]>=h[0]&&min(w[z[0]],w[z[1]])+w[x[0]]>=w[0])
                    puts("4");
                else
                    puts("0");
                continue;
            }
            if (y.size()==1)
            {
                for (int i=1;i<=3;++i)
                    if (i!=y[0]&&i!=x[0])
                        z.push_back(i);
                if (w[x[0]]+w[z[0]]>=w[0]&&h[y[0]]+h[z[0]]>=h[0])
                    puts("4");
                else
                    puts("0");
                continue;
            }
            if (y.size()==2)
            {
                if (h[y[0]]+h[y[1]]>=h[0])
                    printf("%lld\n",2*(w[0]-w[x[0]]+1)%mod);
                else
                    puts("0");
                continue;
            }
        }
        if (x.size()==2)
        {
            if (y.size()==0||y.size()==1)
            {
                for (int i=1;i<=3;++i)
                    if (i!=x[0]&&i!=x[1])
                        z.push_back(i);
                if (w[x[0]]+w[x[1]]>=w[0])
                    printf("%lld\n",2*(h[0]-h[z[0]]+1)%mod*(w[0]-w[z[0]]+1)%mod);
                else
                    puts("0");
                continue;
            }
        }
        if (x.size()==3)
        {
            if (w[1]+w[2]+w[3]>=w[0])
            {
                ll ans=0;
                if (w[1]+w[2]>=w[0])
                    ans+=max(0ll,w[0]-w[3]+1)*2;
                if (w[1]+w[3]>=w[0])
                    ans+=max(0ll,w[0]-w[2])*2;
                if (w[2]+w[3]>=w[0])
                    ans+=max(0ll,w[0]-w[1]-1)*2;
                ans%=mod;
                printf("%lld\n",ans);
            }
            else
                puts("0");
            continue;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

input:

0 1

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements