QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#293327#7785. Three Rectanglesucup-team191#WA 1ms3676kbC++143.8kb2023-12-29 04:34:102023-12-29 04:34:11

Judging History

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

  • [2023-12-29 04:34:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3676kb
  • [2023-12-29 04:34:10]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

typedef long long llint;
typedef pair <int, int> pi;

const int MOD = 1000000007;

int t;
int H, W;
int h[3], w[3];
vector <int> mali, siroki, visoki, cijeli;

int mul (int a, int b) {
    return (llint) a * b % MOD;
}

int add (int a, int b) {
    a += b;
    if (a >= MOD) return a - MOD;
    return a;
}

int sub (int a, int b) {
    a -= b;
    if (a < 0) return a + MOD;
    return a;
}

int broj_nacina_za_jedan_pravokutnik (int i) {
    return mul(H - h[i] + 1, W - w[i] + 1);
}

void swapaj_sve () {
    swap(H, W);
    for (int i = 0; i < 3; i++) {
        swap(h[i], w[i]);
    }
    swap(siroki, visoki);
}

int c_je_srednji (int a, int b, int c) {
    int lo = 0, hi = H - c;
    if (a + b < H) {
        hi = min(hi, a);
        lo = max(lo, H - b - c);
    }
    return hi - lo + 1;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> t;
    while (t--) {
        mali.clear(); visoki.clear(); siroki.clear(); cijeli.clear();

        cin >> H >> W;
        for (int i = 0; i < 3; i++) {
            cin >> h[i] >> w[i];
            if (h[i] == H && w[i] == W) {
                cijeli.push_back(i);
            } else if (h[i] == H) {
                visoki.push_back(i);
            } else if (w[i] == W) {
                siroki.push_back(i);
            } else {
                mali.push_back(i);
            }
        }

        if (visoki.size() > siroki.size()) {
            swapaj_sve();
        }

        int sol;
        if (cijeli.size() > 0) {
            sol = 1;
            for (int i = 0; i < 3; i++) {
                if (i == cijeli[0]) continue;
                sol = mul(sol, broj_nacina_za_jedan_pravokutnik(i));
            }
        } else if (mali.size() == 3) {
            sol = 0;
        } else if (mali.size() == 2) {
            int i = mali[0], j = mali[1], k = siroki[0];
            if (h[i] + h[k] >= H && h[j] + h[k] >= H && w[i] + w[j] >= W) {
                sol = 4;
            } else {
                sol = 0;
            }
        } else if (mali.size() == 1) {
            if (siroki.size() == 1) {
                int i = siroki[0], j = visoki[0], k = mali[0];
                if (h[i] + h[k] >= H && w[j] + w[k] >= W) {
                    sol = 4;
                } else {
                    sol = 0;
                }
            } else {
                int i = siroki[0], j = siroki[1], k = mali[0];
                if (h[i] + h[j] >= H) {
                    sol = mul(2, broj_nacina_za_jedan_pravokutnik(k));
                } else {
                    sol = 0;
                }
            }
        } else {
            if (siroki.size() == 2) {
                int i = siroki[0], j = siroki[1], k = visoki[0];
                if (h[i] + h[j] >= H) {
                    sol = mul(2, broj_nacina_za_jedan_pravokutnik(k));
                } else {
                    sol = 0;
                }
            } else {
                int a = h[0], b = h[1], c = h[2];
                if (a + b + c < H) {
                    sol = 0;
                } else {
                    sol = 0;
                    sol = add(sol, c_je_srednji(a, b, c));
                    sol = add(sol, c_je_srednji(a, c, b));
                    sol = add(sol, c_je_srednji(c, b, a));
                    if (max(a, b) + c >= H) {
                        sol = sub(sol, 1);
                    }
                    if (max(a, c) + b >= H) {
                        sol = sub(sol, 1);
                    }
                    if (max(b, c) + a >= H) {
                        sol = sub(sol, 1);
                    }
                    sol = mul(sol, 2);
                }
            }
        }
        cout << sol << '\n';
    }
    return 0;
}






Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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: 1ms
memory: 3676kb

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:

wrong answer 314th numbers differ - expected: '555555547', found: '0'