QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621236#7785. Three Rectanglesphuong2222WA 3ms3740kbC++143.6kb2024-10-08 11:24:462024-10-08 11:24:46

Judging History

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

  • [2024-10-08 11:24:46]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3740kb
  • [2024-10-08 11:24:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using lli = long long;
const int maxN = 1e6 + 5;
const lli Mod = 1e9 + 7;
lli w[4],h[4];
lli res;
void input()
{
    for (int i = 0;i < 4;++i) cin >> h[i] >> w[i];
}
void solve()
{
    lli val = (1 ^ 2 ^ 3);
    res = 1;
    for (int i = 1;i < 4;++i)
    {
        if (w[i] == w[0] && h[i] == h[0])
        {
            for (int j = 1;j < 4;++j)
            if (j != i) res = (res * (((h[0] - h[j] + 1) * (w[0] - w[j] + 1)) % Mod)) % Mod;
            cout << res << "\n";
            return;
        }
    }
    //cerr << "A";
    res = 0;
    for (int i = 1;i < 4;++i)
    {
        for (int j = i + 1;j < 4;++j)
        {
            if (w[i] == w[j] && w[i] == w[0])
            {
                lli k = (val ^ i ^ j);
                lli wd = max(h[0] - h[i] - h[j],0ll);
                if (wd == 0) res = (res + (2 * ((h[0] - h[k] + 1) * (w[0] - w[k] + 1)) % Mod)) % Mod;
                else if (w[k] == w[0]) res = (res + 2 * min({max(h[k] - wd + 1,0ll),h[i] + 1,h[j] + 1,h[0] - h[k] + 1})) % Mod;
                //cerr << i << " " << j << " " << k << " " << 2 * ((h[0] - h[k] + 1) * (w[0] - w[k] + 1)) << " " << res << "A\n";
                //cerr << i << " " << j << " " << k << " " << 2 * min({max(h[k] - wd + 1,0ll),h[i] + 1,h[j] + 1}) << " " << res << "A\n";
            }
            if (h[i] == h[j] && h[i] == h[0])
            {
                lli k = (val ^ i ^ j);
                lli wd = max(w[0] - w[i] - w[j],0ll);
                //cerr << i << " " << j << " " << k << " " << wd << "\n";
                if (wd == 0) res = (res + 2 * ((h[0] - h[k] + 1) * (w[0] - w[k] + 1)) % Mod) % Mod;
                else if (h[k] == h[0]) res = (res + 2 * min({max(w[k] - wd + 1,0ll),w[i] + 1,w[j] + 1,w[0] - w[k] + 1})) % Mod;
                //cerr << i << " " << j << " " << k << " " << wd << " " << 2 * ((h[0] - h[k] + 1) * (w[0] - w[k] + 1))  << " " << res << "\n";
            }
        }
    }
    //cerr << res << "A\n";
    if (h[1] == h[2] && h[2] == h[3] && h[1] == h[0])
    {
        for (int i = 1;i < 4;++i)
            for (int j = i + 1;j < 4;++j)
            {
                lli k = (val ^ i ^ j);
                if (max(w[i],w[j]) + w[k] >= w[0]) res = (res + Mod - 2) % Mod;
            }
    }
    if (w[1] == w[2] && w[2] == w[3] && w[1] == w[0])
    {
        for (int i = 1;i < 4;++i)
            for (int j = i + 1;j < 4;++j)
            {
                lli k = (val ^ i ^ j);
                if (max(h[i],h[j]) + h[k] >= h[0]) res = (res + Mod - 2) % Mod;
            }
    }
    if (res != 0)
    {cout << res << "\n";return;}
    val = (1 ^ 2 ^ 3);
    for (int i = 1;i < 4;++i)
        for (int j = i + 1;j < 4;++j)
        {
            lli k = (val ^ i ^ j);
            if (h[i] == h[0] && w[j] + w[i] >= w[0])
            {
                lli h1 = h[0] - h[j];
                lli w1 = w[0] - w[i];
                if (w[k] >= w1 && h[k] >= h1) res += 4;
            }
            if (w[i] == w[0] && h[i] + h[j] >= h[0])
            {
                lli h1 = h[0] - h[i];
                lli w1 = w[0] - w[j];
                if (w[k] >= w1 && h[k] >= h1) res += 4;
            }
        }
    //cerr << "A";
    res = res % Mod;
    cout << res << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("P1.inp","r",stdin);
//    freopen("P1.out","w",stdout);
    int t;
    cin >> t;
    for (int i = 1;i <= t;++i)
    {
        input();
        if (t == 5832 && i == 35) for (int j = 0;j < 4;++j) cout << h[j] << " " << w[j] << "\n";
        if (t != 5832) solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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: 3ms
memory: 3668kb

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:

222222222 999999999
111111111 111111111
111111111 222222222
222222222 888888888

result:

wrong answer 1st numbers differ - expected: '0', found: '222222222'