QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#280497#7785. Three Rectanglesucup-team1525#WA 1ms3756kbC++205.8kb2023-12-09 16:30:482023-12-09 16:30:48

Judging History

你现在查看的是最新测评结果

  • [2023-12-09 16:30:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3756kb
  • [2023-12-09 16:30:48]
  • 提交

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)
            {
                ll ans=0;
                int l,r;
                if (h[1]+h[2]>=h[0])
                    ans+=max(0ll,h[0]-h[3]+1)*2;
                else
                {
                    l=max(h[0]-h[2]-h[3],0ll);
                    r=min(h[1],h[0]-h[3]);
                    // cout<<"!"<<l<<' '<<r<<endl;
                    if (l<=r)
                        ans+=2*(r-l+1);
                }
                if (h[1]+h[3]>=h[0])
                    ans+=max(0ll,h[0]-h[2])*2;
                else
                {
                    l=max(h[0]-h[3]-h[2],0ll);
                    r=min(h[1],h[0]-h[2]-1);
                    // cout<<"!"<<l<<' '<<r<<endl;
                    if (l<=r)
                        ans+=2*(r-l+1);
                }
                if (h[2]+h[3]>=h[0])
                    ans+=max(0ll,h[0]-h[1]-1)*2;
                else
                {
                    l=max(h[0]-h[3]-h[1],1ll);
                    r=min(h[2],h[0]-h[1]-1);
                    // cout<<"!"<<l<<' '<<r<<endl;
                    if (l<=r)
                        ans+=2*(r-l+1);
                }
                ans%=mod;
                printf("%lld\n",ans);
            }
        }
        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;
                int l,r;
                if (w[1]+w[2]>=w[0])
                    ans+=max(0ll,w[0]-w[3]+1)*2;
                else
                {
                    l=max(w[0]-w[2]-w[3],0ll);
                    r=min(w[1],w[0]-w[3]);
                    // cout<<"!"<<l<<' '<<r<<endl;
                    if (l<=r)
                        ans+=2*(r-l+1);
                }
                if (w[1]+w[3]>=w[0])
                    ans+=max(0ll,w[0]-w[2])*2;
                else
                {
                    l=max(w[0]-w[3]-w[2],0ll);
                    r=min(w[1],w[0]-w[2]-1);
                    // cout<<"!"<<l<<' '<<r<<endl;
                    if (l<=r)
                        ans+=2*(r-l+1);
                }
                if (w[2]+w[3]>=w[0])
                    ans+=max(0ll,w[0]-w[1]-1)*2;
                else
                {
                    l=max(w[0]-w[3]-w[1],1ll);
                    r=min(w[2],w[0]-w[1]-1);
                    // cout<<"!"<<l<<' '<<r<<endl;
                    if (l<=r)
                        ans+=2*(r-l+1);
                }
                ans%=mod;
                printf("%lld\n",ans);
            }
            else
                puts("0");
            continue;
        }
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

5
2 2
1 1
1 1
1 1
2 2
1 1
1 2
1 2
2 2
1 1
1 2
2 1
2 2
1 2
1 2
1 2
2 2
1 2
1 2
2 1

output:

0
8
4
6
4

result:

ok 5 number(s): "0 8 4 6 4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

4
1 3
1 1
1 2
1 3
1 4
1 1
1 2
1 3
1 5
1 1
1 2
1 3
1 6
1 1
1 2
1 3

output:

6
12
14
6

result:

ok 4 number(s): "6 12 14 6"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

1
1000000000 1000000000
1 1
1 1
1000000000 1000000000

output:

2401

result:

ok 1 number(s): "2401"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

729
999999999 111111111
111111111 111111111
111111111 111111111
111111111 111111111
999999999 111111111
111111111 111111111
222222222 111111111
111111111 111111111
999999999 111111111
111111111 111111111
111111111 111111111
333333333 111111111
999999999 111111111
111111111 111111111
444444444 111111...

output:

0
0
0
0
0
0
6
777777753
456790164
0
0
0
0
0
6
222222208
555555531
135802502
0
0
0
0
6
222222208
222222208
333333309
814814847
0
0
0
6
222222208
222222208
222222208
111111087
493827185
0
0
6
222222208
222222208
222222208
222222208
888888872
172839523
0
6
222222208
222222208
222222208
222222208
222222...

result:

ok 729 numbers

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3756kb

input:

5832
999999999 222222222
111111111 111111111
111111111 111111111
111111111 111111111
222222222 999999999
111111111 111111111
111111111 111111111
111111111 222222222
222222222 999999999
111111111 111111111
111111111 111111111
111111111 333333333
999999999 222222222
111111111 111111111
111111111 11111...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
413046795
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
989330902
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
565615002
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
141899102
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
718183209
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
294467309
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
87...

result:

wrong answer 213th numbers differ - expected: '419753088', found: '666666668'