QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398310#3768. 矩形并Graphcity#AC ✓7ms3572kbC++20952b2024-04-25 10:42:462024-04-25 10:42:46

Judging History

This is the latest submission verdict.

  • [2024-04-25 10:42:46]
  • Judged
  • Verdict: AC
  • Time: 7ms
  • Memory: 3572kb
  • [2024-04-25 10:42:46]
  • Submitted

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e5,Mod=1e9+7;

namespace GRA
{
    int a,b,x1,x2,y1,y2;
    inline void Solve()
    {
        int xk=min(x2,a)-x1,yk=min(y2,b)-y1,ans=0;
        if(xk>0 && yk>0)
        {
            int xs=(1ll*xk*(xk+1)/2)%Mod;
            if(a>x2) xs=(xs+1ll*(a-x2)*xk)%Mod;
            int ys=(1ll*yk*(yk+1)/2)%Mod;
            if(b>y2) ys=(ys+1ll*(b-y2)*yk)%Mod;
            ans=1ll*xs*ys%Mod;
        }
        int all=1ll*(x2-x1)*(y2-y1)%Mod*a%Mod*b%Mod;
        int as=(1ll*a*(a+1)/2)%Mod,bs=(1ll*b*(b+1)/2)%Mod;
        int cur=1ll*as*bs%Mod;
        ans=(1ll*all+cur-ans+Mod)%Mod; cout<<ans<<endl;
    }
    inline void Run()
    {
        while(cin>>a>>b>>x1>>x2>>y1>>y2) Solve();
    }
}

int main()
{
    // freopen("1.in","r",stdin);

    GRA::Run();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 3572kb

input:

1 1
2 3 2 3
10 10
1 5 1 5
1000000000 1000000000
1 1000000000 1 1000000000
1 2
2 5 1 4
2 5
1 5 2 4
1 4
3 4 1 5
2 3
1 4 2 4
5 3
1 4 1 2
5 2
3 5 4 5
3 2
3 5 1 4
5 3
4 5 1 3
5 5
1 5 2 5
4 4
1 5 2 5
1 2
1 5 3 5
3 4
3 4 1 2
2 2
1 4 1 3
3 1
1 4 1 4
2 4
1 5 2 5
4 2
2 3 3 5
1 3
1 2 1 2
2 4
1 3 1 5
5 2
2 3 2 ...

output:

2
3725
2793
21
120
26
53
117
65
54
117
465
274
19
72
32
33
123
46
9
88
65
36
252
83
159
17
330
261
186
84
26
45
34
75
34
65
30
88
107
12
105
38
46
15
85
29
55
78
55
96
17
39
60
20
17
56
45
5
18
96
30
25
108
146
114
65
19
192
51
17
42
54
132
110
75
42
75
66
150
7
7
173
33
95
75
294
45
247
25
35
110
2...

result:

ok 10000 lines