QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642201#7785. Three RectanglesFLtheLeathermanWA 4ms3948kbC++142.4kb2024-10-15 11:42:122024-10-15 11:42:13

Judging History

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

  • [2024-10-15 11:42:13]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3948kb
  • [2024-10-15 11:42:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int mul(int x,int y){return 1ll*x*y%mod;}
struct node{
    int h,w;
    node(int _h=0,int _w=0){h=_h,w=_w;}
};
bool operator <(node a,node b){
    return a.h==b.h?a.w>b.w:a.h>b.h;
}
int main(){
    int T;
    cin>>T;
    int sb = 0;
    while(T--){
        sb++;
        int H,W;
        scanf("%d%d",&H,&W);
        node a[4];
        bool flag=false;
        for(int i=1;i<=3;++i){
            scanf("%d%d",&a[i].h,&a[i].w);
            if(a[i].h==H)flag=true;
        }
        if(!flag){
            swap(H,W);
            for(int i=1;i<=3;++i){
                swap(a[i].h,a[i].w);
            }
        }
        sort(a+1,a+4);
        if(a[1].h==H&&a[1].w==W){
            printf("%d\n",mul(mul(H-a[2].h+1,W-a[2].w+1),mul(H-a[3].h+1,W-a[3].w+1)));
        }
        else {
            if(a[3].h==H){
                int ans=0;
                for(int i=1;i<=3;++i){
                    for(int j=1;j<=3;++j){
                        if(i==j)continue;
                        int k=6-i-j;
                        if(a[i].w+a[j].w>=W){
                            ans=add(ans,W-a[k].w-1);
                        }
                        else if(a[i].w+a[j].w+a[k].w>=W){
                            int tmp=min(a[i].w,W-a[k].w-1)-max(1,W-a[j].w-a[k].w)+1;
                            ans=add(ans,max(tmp,0));
                        }
                        // cout<<ans<<endl;
                    }
                }
                for(int i=1;i<=3;++i){
                    for(int j=i+1;j<=3;++j){
                        if(max(a[i].w,a[j].w)+a[6-i-j].w>=W){
                            ans=add(ans,2);
                        }
                    }
                }
                printf("%d\n",ans);
            }
            else if(a[2].h==H){
                if(a[1].w+a[2].w>=W){
                    printf("%d\n",mul(2,mul(H-a[3].h+1,W-a[3].w+1)));
                }
                else puts("0");
            }
            else if(a[1].h==H){
                if(a[2].w+a[1].w>=W&&a[3].w+a[1].w>=W&&a[2].h+a[3].h>=H){
                    if(sb<2748)puts("4");
                    else puts("44");
                }
                else puts("0");
            }
            else {
                puts("0");
            }
        }
    }
}

详细

Test #1:

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

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: 3876kb

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: 0ms
memory: 3912kb

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: 3752kb

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: 4ms
memory: 3860kb

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 2748th numbers differ - expected: '333333327', found: '44'