QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#281367#7785. Three Rectanglesucup-team2894#WA 0ms3544kbC++143.4kb2023-12-10 03:23:032023-12-10 03:23:03

Judging History

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

  • [2023-12-10 03:23:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2023-12-10 03:23:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

long long H, W;
pair<long long, long long> arr[3];
const long long MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--) {
        cin >> H >> W;
        int hcnt = 0;
        int wcnt = 0;
        bool tot = 0;
        for (int i = 0; i < 3; i++) {
            cin >> arr[i].first >> arr[i].second;
            if (arr[i].first == H && arr[i].second == W) {
                tot = 1;
            }
            else if (arr[i].first == H) {
                wcnt++;
            }
            else if (arr[i].second == W) {
                hcnt++;
            }
        }
        if (tot) {
            long long ans = 1;
            for (auto p : arr) {
                ans *= (H - p.first + 1) * (W - p.second + 1) % MOD;
                ans %= MOD;
            }
            cout << ans << "\n";
            continue;
        }

        if (wcnt >= 2) {
            swap(wcnt, hcnt);
            swap(H, W);
            for (auto& p : arr) {
                swap(p.first, p.second);
            }
        }

        if (hcnt == 3) {
            vector<int> v = {0, 1, 2};
            long long ans = 0;
            do {
                long long gap = H - arr[v[0]].first - arr[v[1]].first;
                gap = max(gap, 0LL);

                if (gap == 0) {
                    ans += H - arr[v[2]].first + 1;
                }
                else {
                    long long r = min(arr[v[0]].first, H - arr[v[2]].first);
                    long long l = max(arr[v[0]].first + gap - arr[v[2]].first, 0LL);
                    ans += r - l + 1;
                }
                // cout << arr[v[0]].first << " " << arr[v[1]].first << " " << arr[v[2]].first << " " << H << " " << ans << "\n";

                if (max(arr[v[0]].first, arr[v[1]].first) + arr[v[2]].first >= H) {
                    ans--;
                }
                // cout << arr[v[0]].first << " " << arr[v[1]].first << " " << arr[v[2]].first << " " << H << " " << ans << "\n";
            }
            while(next_permutation(v.begin(), v.end()));
            cout << ans % MOD << "\n";
            continue;
        }
        else if (hcnt == 2) {
            long long sum = 0;
            long long ans = 0;
            for (auto& p : arr) {
                if (p.second == W) {
                    sum += p.first;
                }
                else {
                    ans = 2 * (H - p.first + 1) * (W - p.second + 1) % MOD;
                }
            }
            cout << (sum >= H) * ans << "\n";
            continue;
        }

        if (wcnt >= 1) {
            swap(wcnt, hcnt);
            swap(H, W);
            for (auto& p : arr) {
                swap(p.first, p.second);
            }            
        }

        if (hcnt >= 1) {
            for (int i = 0; i < 3; i++) {
                if (arr[i].second == W) {
                    swap(arr[0], arr[i]);
                    break;
                }
            }
            if (arr[0].first + min(arr[1].first, arr[2].first) >= H && arr[1].second + arr[2].second >= W) {
                cout << 4 << "\n";
            }
            else {
                cout << 0 << "\n";
            }
        }
        else {
            cout << 0 << "\n";
        }
    }
}

詳細信息

Test #1:

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

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

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

input:

1
1000000000 1000000000
1 1
1 1
1000000000 1000000000

output:

2401

result:

ok 1 number(s): "2401"

Test #4:

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

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:

-999999969
-333333303
-666666644
-999999985
-333333319
-666666660
6
777777753
456790164
-333333303
-666666644
-999999985
-333333319
-666666660
6
222222208
555555531
135802502
-666666644
-999999985
-333333319
-666666660
6
222222208
222222208
333333309
814814847
-999999985
-333333319
-666666660
6
2222...

result:

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